#!/usr/bin/perl
#
#sysinfo.pl - grabs various bits of system status information from standard
#       UNIX utilities, generates PHP code and pushes it onto a webserver. 
#       Desinged to be used to display the status of all network machines on
#       your webserver


chomp($hostname=`hostname`);
$uptime=`uptime`;
$uname=`uname -a`;
$df=`df -h`;
$cpu=`cat /proc/cpuinfo | grep model\\name`;
$free=`free -m`;
$netstat=`netstat -i`;

open(OUT, ">$hostname.html");
print OUT "<html><body>";
print OUT "<b>hostname</b><pre>$hostname</pre>";
print OUT "<b>uname -a</b><pre>$uname</pre>";
print OUT "<b>uptime</b><pre>$uptime</pre>";
print OUT "<b>free -m</b><pre>$free</pre>";
print OUT "<b>df -h</b><pre>$df</pre>";
print OUT "<b>netstat -i</b><pre>$netstat</pre>";
print OUT "</body><br></html>";
close(OUT);

# you will need to replace <your server> with the address of the server you are ryncing
# to, and <your directory> with a directory you can put this file in
system("rsync -t *.html <yourserver>:<directory>/");

# to make use of the file, just use simple Server Side Include statements, such as:
#  <!--#include file="<hostname>.html" -->
# <hostname> needs to be replaced with the name of the host you are running this script
# on.  Place that include statement in an html file in your webserver, and then add this
# perl script to crontab on your local machine and you're good to go!
