#!/usr/bin/perl
use IO::File;
use GD;
use Time::localtime;
use LWP::Simple;
use LWP::UserAgent;
use DB_File;
use Fcntl;



my($memsize,$memfree,$buffers,$cached,$memused,$swaptotal,$swapfree,$swapused) = meminfo();
my($cpu,$cache,$cores,$mhz) = cpuinfo();
my($netin,$netout) = netinfo();
my($days) = uptime();

sub meminfo{
	my($memsize,$memfree,$buffers,$cached,$memused,$swaptotal,$swapfree,$swapused);
	open(MEMINFO, "/proc/meminfo") or return undef;
	while(<MEMINFO>){
		chomp;
		if(/^MemTotal:\s+(\d+)/){
			$memsize = sprintf("%.2f",$1/1024);
		}elsif(/^MemFree:\s+(\d+)/){
			$memfree = sprintf("%.2f",$1/1024);
#Buffers:         82248 kB
#Cached:        1314520 kB

		}elsif(/^Buffers:\s+(\d+)/){
			$buffers = sprintf("%.2f",$1/1024);
                }elsif(/^Cached:\s+(\d+)/){
                        $cached = sprintf("%.2f",$1/1024);

		}elsif(/^SwapTotal:\s+(\d+)/){
			$swaptotal = sprintf("%.2f",$1/1024);
		}elsif(/^SwapFree:\s+(\d+)/){
			$swapfree = sprintf("%.2f",$1/1024);
		}
   	}
	my $memused = sprintf("%.2f" ,$memsize - $memfree);
	my $swapused = sprintf("%.2f" ,$swaptotal - $swapfree);
	close(MEMINFO);
	return($memsize,$memfree,$buffers,$cached,$memused,$swaptotal,$swapfree,$swapused);
}

sub cpuinfo{
	my($cpu,$cache,$cores,$mhz);
	open(CPUINFO, "/proc/cpuinfo") or return undef;
	while(<CPUINFO>){
		chomp;
                if(/^model name\s+\:\s+(.*?)$/){
#model name	: Intel(R) Core(TM)2 Quad  CPU   Q9450  @ 2.66GHz
                        $cpu = $1;
                }elsif(/^cache size\s+:\s+([\d\.]*)/){
#cache size	: 6144 KB
                        $cache = $1;
                }elsif(/^cpu cores\s+:\s+(\d+)/){
#cpu cores	: 4
                        $cores = $1;
#cpu MHz		: 3304.131
		}elsif(/^cpu MHz\s+:\s+([\d\.]*)/){
			$mhz = $1;
                }
        }
	close(CPUINFO);
        if ($cores == ""){
                $cores = 1;
        }

	return($cpu,$cache,$cores,$mhz);
}

sub netinfo{
	my($netin,$netout);
	open(NETINFO, "/proc/net/dev") or return undef;
	while(<NETINFO>){
		chomp;
		if(/^\s+(.*?):(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+/){
#		# eth0:1062991973 5083742    0    0    0     0          0         0 265559036 2897289    0    0    0     0       0          0

			$netin = sprintf("%.2f",$2 / 1048576);
			$netout = sprintf("%.2f",$3 / 1048576);

		}
	}
	close(NETINFO);
	return($netin,$netout);
}

sub uptime{
	my ($days);
	open (UPTIME, "/proc/uptime") or return undef;
	while (<UPTIME>){
		chomp;
		if(/(\d+\.\d+)\s+\d+\.+\d+/){
		#288359.76 15415.53
			$days = sprintf("%.2f",$1 / 86400);
		}
	}
	close (UPTIME);
	return ($days);
}

chomp(my $uname = `uname -sr`);




############CREATE BASIC CHART LAYOUT PRIOR TO DATA LINES
my $im = new GD::Image(170,230);

# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
$green = $im->colorAllocate(0,255,0);
$yellow = $im->colorAllocate(255,255,0);
$orange = $im->colorAllocate(255,128,0);
$purple = $im->colorAllocate(255,0,255);
$brown = $im->colorAllocate(128,64,0);
        
$im->fill(0,0,$white);

#$im->string(gdSmallFont,400,50,"Memory Usage",$black);
$im->line(50,10,50,210,$black);
$im->line(10,210,110,210,$black);
$im->string(gdSmallFont,5,5,"MB",$black);
$im->string(gdSmallFont,50,215,"Current Usage",$black);


#coordinate
my $num3 = 210;
#points
my $num4 = 0;
my $tenth = $memsize / 10;


use POSIX qw(ceil);

for ($i = 0; $i < 11; ++$i)
{
        $im->string(gdSmallFont,25,$num3,$num4,$black);
        $im->line(25,$num3,30,$num3,$black);
        $im->setStyle($yellow,$yellow,$yellow,$yellow,$blue,$blue,$blue,$blue,gdTransparent,gdTransparent);
        $im->dashedLine(30,$num3,110,$num3,gdStyled);
        $num4 = $num4 + $tenth;
	$num4 = ceil($num4);
        $num3 = $num3 - 20;
}


#total used
#$num3 = 200 - ($memused / $memsize * 200);
#$num3 = $num3 + 10;
$num3 = $memused / $memsize;
$num3 = $num3 * 200;
$num3 = 200 - $num3;
$num3 = $num3 + 10;


#cached
#my $num4 = $cached / 1024;
$num4 = $cached/$memsize;  
$num4 = $num4 * 200;
$num4 = 200 - $num4;
$num4 = $num4 + 10;

#buffers used
#my $num5 = $buffers / 1024;
#$num5 = 200 + ($buffers / $memsize * 200);
#$num5 = $num5 + 10;
$num5 = $buffers + $cached;
$num5 = $num5 / $memsize;
$num5 = $num5 * 200;
$num5 = 200 - $num5;
$num5 = $num5 + 10;


#$im->line(60,$num3,60,210,$red);
#$im->line(60,$num3,110,$num3,$red);
#$im->line(85,$num3,85,210,$red);
#$im->line(110,$num3,110,210,$red);
#$im->line(60,$num3,110,210,$red);
#$im->line(110,$num3,60,210,$red);


#$num5 = $num5 - $num4 + 10;



#total used
$im->filledRectangle(60,$num3,110,210,$red);
#buffers
$im->filledRectangle(60,$num4,110,$num5,$yellow);
#cached
$im->filledRectangle(60,210,110,$num4,$orange);
#free
$im->filledRectangle(60,10,110,$num3,$green);


$im->string(gdSmallFont,120,10,Free,$black);
$im->string(gdSmallFont,120,70,Other,$black);
$im->string(gdSmallFont,120,130,Buffers,$black);
$im->string(gdSmallFont,120,190,Cached,$black);
$im->line(110,10,120,10,$black);
$im->line(110,$num3,120,70,$black);
$im->line(110,$num5,120,130,$black);
$im->line(110,$num4,120,190,$black);



##############GD STUFF FOR FINAL IMAGE
# make sure we are writing to a binary stream
#binmode STDOUT;
# Convert the image to PNG and print it on standard output
#print $im->png;

#initialize to delete old data
#open FILE1, ">", "/tmp/mem.png" or die $!;
#close(FILE1);

open FILE1, "> /var/www/htdocs/lsnet/mem.png" or die $!;

 #       while (<FILE1>) {
#		print FILE1 $im->png;
#	}

binmode FILE1;
print FILE1 $im->png;


close(FILE1);



############# CREATE 2nd mem graph for last 24hrs
my $stop = 1;

while ( $stop == 1)
{
	if (-e "/tmp/lsmemlock")
	{
		$stop = 1;
		sleep(1);
	} else {
		$stop = 0;
	}
}

#create lock file
open lsmemlock, ">/tmp/lsmemlock";

#opening database   
tie (%lsmem_db, DB_File, "/tmp/lsmem.db") ||
die ("Cannot open /tmp/lsmem.db");
#86400 seconds per day

my $im = new GD::Image(1620,255);


# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
$green = $im->colorAllocate(0,255,0);
$yellow = $im->colorAllocate(255,255,0);
$orange = $im->colorAllocate(255,128,0);
$purple = $im->colorAllocate(255,0,255);
$brown = $im->colorAllocate(128,64,0);


$im->fill(0,0,$white);
#$im->string(gdSmallFont,400,50,"Memory Usage",$black);  
$im->line(50,10,50,210,$black);
$im->line(10,210,110,210,$black);
$im->string(gdSmallFont,5,5,"MB",$black);
$im->string(gdSmallFont,50,240,"Hours",$black);
#use POSIX qw(ceil);

#coordinate
my $num3 = 210;
#points
my $num4 = 0;
my $tenth = $memsize / 10;


#use POSIX qw(ceil);

for ($i = 0; $i < 11; ++$i)
{
        $im->string(gdSmallFont,25,$num3,$num4,$black);
        $im->line(25,$num3,30,$num3,$black);
        $im->setStyle($yellow,$yellow,$yellow,$yellow,$blue,$blue,$blue,$blue,gdTransparent,gdTransparent);
        $im->dashedLine(30,$num3,1500,$num3,gdStyled);
        $num4 = $num4 + $tenth;
        $num4 = ceil($num4);
        $num3 = $num3 - 20;
}



my $lastentry = $lsmem_db{"mem0"};
my $hournum = 60;
for ($i = 1; $i < 25; ++$i)
{
        $im->string(gdSmallFont,$hournum,220,$i,$black);
        $im->line($hournum,210,$hournum,220,$black);
        #$im->setStyle($yellow,$yellow,$yellow,$yellow,$blue,$blue,$blue,$blue,gdTransparent,gdTransparent);
        #$im->dashedLine(30,$num3,110,$num3,gdStyled);
        #$num4 = $num4 + $tenth;
        #$num4 = ceil($num4);
        #$num3 = $num3 - 20;
	$hournum = $hournum + 60;
	#my($memsize,$memfree,$buffers,$cached,$memused,$swaptotal,$swapfree,$swapused) = meminfo();
	#Wed Feb  4 10:03:37 2009 2026.77 437.45 459.96 459.29 1589.32 10722.93 10722.92 0.01
	#86400 seconds in day
	#every 10min =144pixels/day@1px/10min  (600s/10m)
}

#my $num = 1;

my $coordinate = 1500;
$hournum = 60;

my $var2 = $lsmem_db{"mem0"};
for ($i = 1440; $i > 0; --$i)
{
	#my $var = $lsnet_db{"mem$num"};
	if (exists $lsmem_db{"mem$lastentry"}) 
	{
		#my $var2 = $lsnet_db{"mem0"};
		if ($lastentry >= 1)
		{
			my $var = $lsmem_db{"mem$lastentry"};	
			$var =~ /.{3}\s+(.{3})\s+(\d{1,2})\s+(\d{2}).(\d{2}).(\d{2})\s+(\d{4})\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s*/;
			#Sat Feb  7 14:19:32 2009
			my $dbmemsize = sprintf("%.2f",$7);
			my $dbmemfree = sprintf("%.2f",$8);
			my $dbbuffers = sprintf("%.2f",$9);
			my $dbcached = sprintf("%.2f",$10); 
			my $dbmemused = sprintf("%.2f",$11);
			my $month = sprintf("%s",$1);
			my $day = sprintf("%u",$2);
			my $hour = sprintf("%u",$3);
			my $min = sprintf("%u",$4);
			my $sec = sprintf("%u",$5);
			my $year = sprintf("%u",$6);

	
			#print "\ndbmemsize $dbmemsize\n";
			#print "dbmemfree $dbmemfree\n";
			#print "dbbuffers $dbbuffers\n";
			#print "dbcached $dbcached\n";
			#print "dbmemused $dbmemused\n";

	
			#my $dbswaptotal = $lsnet_db{"mem$num"};
			#my $dbswapfree = $lsnet_db{"mem$num"};
			#my $dbswapused = $lsnet_db{"mem$num"};

			#total used
			#$num3 = 200 - ($dbmemused / $dbmemsize * 200);
			#$num3 = $num3 + 10;
			$num3 = $dbmemused / $dbmemsize;
			$num3 = $num3 * 200;
			$num3 = 200 - $num3;
			$num3 = $num3 + 10; 

			#cached
			#my $num4 = $cached / 1024;
			$num4 = $dbcached/$dbmemsize;
			$num4 = $num4 * 200;
			$num4 = 200 - $num4;
			$num4 = $num4 + 10;

			#buffers used
			#my $num5 = $buffers / 1024;
			#$num5 = 200 + ($buffers / $memsize * 200);
			#$num5 = $num5 + 10;
			$num5 = $dbbuffers + $dbcached;
			$num5 = $num5 / $dbmemsize;
			$num5 = $num5 * 200;
			$num5 = 200 - $num5;
			$num5 = $num5 + 10;

			#my $coordinate = $hournum + 10;
                        if ($lastentry == $var2)
                        {
                                $im->string(gdSmallFont,1540,10,Free,$black);
                                $im->string(gdSmallFont,1540,70,Other,$black);
                                $im->string(gdSmallFont,1540,130,Buffers,$black);
                                $im->string(gdSmallFont,1540,190,Cached,$black);
                                $im->line(1500,10,1540,10,$black);
                                $im->line(1500,$num3,1540,70,$black);
                                $im->line(1500,$num5,1540,130,$black);
                                $im->line(1500,$num4,1540,190,$black);
                        }
			#total used
			$im->line($coordinate,$num3,$coordinate,210,$red);
			#buffers
			$im->line($coordinate,$num4,$coordinate,$num5,$yellow);
			#cached
			$im->line($coordinate,210,$coordinate,$num4,$orange);
			#free
			$im->line($coordinate,10,$coordinate,$num3,$green);

			#total used
			#$im->filledRectangle($i,$num3,$coordinate,210,$red);
			#buffers
			#$im->filledRectangle($hournum,$num4,$coordinate,$num5,$yellow);
			#cached
			#$im->filledRectangle($hournum,210,$coordinate,$num4,$orange);
			#free
			#$im->filledRectangle($hournum,10,$coordinate,$num3,$green);
		}
	}
		$coordinate--; 
		$hournum = $hournum + 10;
		$lastentry--;
	
}

#close database  
untie(%lsmem_db);

#remove lock file
close lsmemlock;
unlink "/tmp/lsmemlock";



open FILE1, "> /var/www/htdocs/lsnet/mem2.png" or die $!;
binmode FILE1;
print FILE1 $im->png;
close(FILE1);  


################ 3RD IMAGE NETWORK USAGE
$stop = 1;

while ( $stop == 1 )
{
        if (-e "/tmp/lsniclock")
        {
                $stop = 1;
                sleep(1);
        } else {
                $stop = 0;
        }
}

#create lock file
open lsniclock, ">/tmp/lsniclock";

#opening database
tie (%lsnic_db, DB_File, "/tmp/lsnic.db") ||
die ("Cannot open /tmp/lsnic.db");

my $im = new GD::Image(1600,255);


# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
$green = $im->colorAllocate(0,255,0);
$yellow = $im->colorAllocate(255,255,0);
$orange = $im->colorAllocate(255,128,0);
$purple = $im->colorAllocate(255,0,255);
$brown = $im->colorAllocate(128,64,0);


$im->fill(0,0,$white);
#$im->string(gdSmallFont,400,50,"Network Usage",$black);
$im->line(50,10,50,210,$black);
$im->line(10,210,110,210,$black);
$im->string(gdSmallFont,1,1,"KB/s",$black);
$im->string(gdSmallFont,50,240,"Hours",$black);
$im->filledRectangle(1520,65,1540,85,$red);
$im->string(gdSmallFont,1545,85,"Upload",$red);
$im->filledRectangle(1520,105,1540,125,$green);
$im->string(gdSmallFont,1545,125,"Download",$green);  



#use POSIX qw(ceil);

#coordinate
$num3 = 210;
#points
$num4 = 0;

my $max = 0;
my $oldmax = 0;
my $lastentry = $lsnic_db{"net0"};

#my $var2 = $lsnet_db{"net0"};
for ($i = 1440; $i > 0; --$i)  
{
        if (exists $lsnic_db{"net$lastentry"})
        {
                if ($lastentry >= 1)
                {
			$var = $lsnic_db{"net$lastentry"};
                        $var =~ /.{3}\s+.{3}\s+\d{1,2}\s+\d\d.\d\d.\d\d\s+\d{4}\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s*/;
			#Fri Feb  6 12:13:52 2009 0.0699999999999932 0.00999999999999091 855 45
			#$string = ("$datetime $nin $nout $pin $pout");
                        my $netin = sprintf("%.2f",$1);
                        my $netout = sprintf("%.2f",$2);
                        my $packin = sprintf("%.2f",$3);
                        my $packout = sprintf("%.2f",$4);
                        #my $dbmemused = sprintf("%.2f",$5);
			my $max = sprintf("%.2f",$1 + $2);
			if ($max > $oldmax)
			{
				$oldmax = $max;
			}

		}

	}
	$lastentry--;
}

#$oldmax = 100000;
#convert from MB/Min to KB/Sec
$oldmax = $oldmax / 60; 
$oldmax = $oldmax * 1024;

$tenth = $oldmax / 10;
#highest of $nin + $nout from last 1440 entries 


#use POSIX qw(ceil);

for ($i = 0; $i < 11; ++$i)
{
        $im->string(gdSmallFont,25,$num3,$num4,$black);
        $im->line(25,$num3,30,$num3,$black);
        $im->setStyle($yellow,$yellow,$yellow,$yellow,$blue,$blue,$blue,$blue,gdTransparent,gdTransparent);
        $im->dashedLine(30,$num3,1500,$num3,gdStyled);
        $num4 = $num4 + $tenth;
        $num4 = ceil($num4);   
        $num3 = $num3 - 20;
}

$lastentry = $lsnic_db{"net0"};
$hournum = 60;
for ($i = 1; $i < 25; ++$i)
{
        $im->string(gdSmallFont,$hournum,220,$i,$black);
        $im->line($hournum,210,$hournum,220,$black);
        $hournum = $hournum + 60;
        #86400 seconds in day
        #every 10min =144pixels/day@1px/10min  (600s/10m)
}
        
                        
$coordinate = 1500;
$hournum = 60;

$var2 = $lsnic_db{"net0"};
for ($i = 1440; $i > 0; --$i)
{
        if (exists $lsnic_db{"net$lastentry"})
        {               
                if ($lastentry >= 1)
                {
                        $var = $lsnic_db{"net$lastentry"};
                        $var =~ /.{3}\s+.{3}\s+\d{1,2}\s+.{8}\s+\d{4}\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s*/;
                        my $netin = sprintf("%.2f",$1/60*1024);
                        my $netout = sprintf("%.2f",$2/60*1024);
                        my $packin = sprintf("%.2f",$3);
                        my $packout = sprintf("%.2f",$4);
			$max = $netin + $netout;
			
			#netin = green (on bottom)  netout = red (on top)
			
			#top of netout
                        $num3 = $max/$oldmax;
                        $num3 = $num3 * 200;
                        $num3 = 200 - $num3;
                        $num3 = $num3 + 10;

                        #top of netin
                        $num4 = $netin/$oldmax;
                        $num4 = $num4 * 200;
                        $num4 = 200 - $num4;
                        $num4 = $num4 + 10;
                        
			#only if it is the most recent db entry drawl labels first
                        #if ($lastentry == $var2)
                        #{
                        #        $im->string(gdSmallFont,1540,10,Free,$black);
                        #        $im->string(gdSmallFont,1540,70,Other,$black);
                        #        $im->string(gdSmallFont,1540,130,Buffers,$black);
                        #        $im->string(gdSmallFont,1540,190,Cached,$black);
                        #        $im->line(1500,10,1540,10,$black);
                        #        $im->line(1500,$num3,1540,70,$black);
                        #        $im->line(1500,$num5,1540,130,$black);
                        #        $im->line(1500,$num4,1540,190,$black);
                        #}


                        #net out line
                        $im->line($coordinate,$num3,$coordinate,210,$red);
                        #net in line
                        $im->line($coordinate,$num4,$coordinate,210,$green);
                        #blank space above
                        #$im->line($coordinate,10,$coordinate,$num3,$green);

                }
        }
                $coordinate--;
                $hournum = $hournum + 10;
                $lastentry--;

}

#close database  
untie(%lsnic_db);

#remove lock file
close lsniclock;
unlink "/tmp/lsniclock";

open FILE1, "> /var/www/htdocs/lsnet/net.png" or die $!;
binmode FILE1;
print FILE1 $im->png;
close(FILE1);

my $ua = LWP::UserAgent->new(agent => "google suck");
my $result = $ua->get($url);

my $site1=get "http://linuxsociety.org/cgi-bin/lsnet2.pl";
my $site2=get "http://70.166.30.8/cgi-bin/lsnet2.pl";
my $site3=get "http://linuxsociety.org/lsnet/netinout";
my $site4=get "http://70.166.30.8/lsnet/netinout";

#lynx -dump http://linuxsociety.org/cgi-bin/lsnet.pl
#lynx -dump http://70.166.30.8/cgi-bin/lsnet.pl

#$site1 =~ /.{12}\n*\s*.{27}\n*\s*.{5}\s.{17}\s.{14}\s.{14}\s.{15}\n*\s*\n*(.*\s.*\s.*)\s.{4}(.*\s.*\s.*).{4}(.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*)\s*.{4}(.*\s*.*\s*.*\s*.*)\s*.{4}(.*\s*.*\s*.*\s*.*)\s*.{4}(.*\s*.*\s*.*)\s*.{4}(.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*\s*.*)\s*.{4}(.*/s*.*/s*.*/s*.*/s*.*)/s*.{4}(.*/s*.*/s*.*/s*.*/s*.*)/s*.{18}/s*/;


print "Content-type: text/html\n\n";
print "<html><head>\n";
print "<title>stats</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" link=\"#800000\">\n";
print "<br>";
print "<span style=\"color: rgb(2, 2, 255);font-size: 25;\">sterlingdesktops.com<br></span>";

#print "sterlingdesktops.com <br>";
print "OS: $uname <br>";
print "Uptime: $days Days<br>";
print "CPU Type: $cpu <br>";
print "CPU Clock: $mhz MHz <br>";
print "CPU Cache: $cache KB<br>";
print "CPU Cores: $cores <br>";
#print "Memory: $memused / $memsize MB <br>";
#print "Swap: $swapused / $swaptotal MB <br>"; 
#print "Network in/out: $netin / $netout MB (since last device reset) <br>";
#print "<img alt=\"net\" title=\"network usage\" src=\"http://sterlingdesktops.com/lsnet/net.png\"></img>";
#print "<br>";
#print "$swaptotal $swapfree <br>";
print "Swap: $swapused / $swaptotal MB <br><br>";
print "Memory: $memused / $memsize MB <br>";
#print "<img alt=\"mem\" title=\"memory usage\" src=\"/lsnet/mem.png\"></img>";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://sterlingdesktops.com/lsnet/mem.png\"></img>";
print "<br>";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://sterlingdesktops.com/lsnet/mem2.png\"></img>";
print "<br><br>";
print "Network in/out: $netin / $netout MB (since last device reset) <br>";
print "<img alt=\"net\" title=\"network usage\" src=\"http://sterlingdesktops.com/lsnet/net.png\"></img>";
print "<br><br>";
print "$site1";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://linuxsociety.org/lsnet/mem.png\"></img>";
print "<br>";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://linuxsociety.org/lsnet/mem2.png\"></img>";
print "<br><br>";
print "$site3";
print "<img alt=\"net\" title=\"network usage\" src=\"http://linuxsociety.org/lsnet/net.png\"></img>";
print "<br><br>";
print "$site2";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://70.166.30.8/lsnet/mem.png\"></img>";
print "<br>";
print "<img alt=\"mem\" title=\"memory usage\" src=\"http://70.166.30.8/lsnet/mem2.png\"></img>";
print "<br><br>";
print "$site4";
print "<img alt=\"net\" title=\"network usage\" src=\"http://70.166.30.8/lsnet/net.png\"></img>";
print "</body></html>\n";
