head     1.1;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.1
date     94.11.18.15.31.27;  author mkgray;  state Exp;
branches ;
next     ;


desc
@Script to report the current web server load
@



1.1
log
@Initial revision
@
text
@#!/usr/local/bin/perl

open(LOG, "/var/local/www/logs/access_log");

$lastblock = `tail -1000 /var/local/www/logs/access_log`;
($nowsec, $nowmin, $nowhour, @@rest) = localtime(time);
$lastblock =~ /\[\d+\/...\/\d\d\d\d:(\d\d):(\d\d):(\d\d)/;
$hour = $1; $min = $2; $sec = $3;
$# = '%.2g';
print("Content-type: text/html\n\n");

$nowhour += 24 if $hour > $nowhour;

$time = $hour*3600+$min*60+$sec;
$nowtime = $nowhour*3600+$nowmin*60+$nowsec;
$diff = $nowtime-$time;
$connpersec = int(100000/$diff)/100;
print("<h1>SIPB Web server load</h1>\n");
$connpermin = $connpersec*60;
print("<ul>\n");
printf("<li>%.2f connections per second (%.2f conn/minute)\n", $connpersec, $connpermin);
print("<li>To be exact, 1000 connections in the last $diff seconds\n");
$uptime = `uptime`;
($uptime1, $uptime2) = split(/load average: /, $uptime);
print("<li><tt>$uptime1</tt>\n");
print("<li>Load values: <tt>$uptime2</tt>\n");
print("</ul>\n");
@
