Location: PHPKode > scripts > rrd4sar > rrd4sar.php
<?php
/*
RRD4SAR
Description: Fetch SAR statistics for a selected day for a selected remote machine and display them graphically. Uses RRDtool (Copyright 1997-2004 by Tobias Oetiker ), SAR command authored by Sebastien Godard & PHP(libssh2).
License: Distributed under GNU GENERAL PUBLIC LICENSE - Version 3
Author: Praveen Kumar K S
Download: http://www.chakravaka.com/rrd4sar/rrd4sar.tar.gz)

    Copyright (C) 2010 Praveen Kumar K S

    This file is part RRD4SAR.

    RRD4SAR program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

require_once "cls.poller.php";

$l_poller=new sarPoller("rrd4sar.ini","hosts.ini");
$l_html="<html><head></head><body><div style='font:10px verdana;'><center>RRD4SAR</center>";
$l_html.="<hr>Description: Fetch SAR statistics for a selected day for a selected remote machine and display them graphically. Uses RRDtool (Copyright 1997-2004 by Tobias Oetiker <hide@address.com>), SAR command authored by Sebastien Godard & PHP(libssh2).";
$l_html.="<br>License: Distributed under GNU GENERAL PUBLIC LICENSE - Version 3";
$l_html.="<br>Author: Praveen Kumar K S";
$l_html.="<br>Download: http://www.chakravaka.com/rrd4sar/rrd4sar.tar.gz)<hr></div>";
$l_html.="<div><form>";
$l_html.="<select style='height:30;font:9px verdana;' name='rhost'>";
$l_html.="<option value=''>SELECT HOST</option>";
foreach($l_poller->hosts as $l_host => $l_host_details)
{
	$l_html.="<option value='$l_host'";
	if($_REQUEST["rhost"]==$l_host)
	{
		$l_html.=" selected";
	}
	$l_html.=">$l_host</option>";
}
$l_html.="</select>";
$l_html.="<select style='height:30;font:9px verdana;' name='day'>";
$l_html.="<option value=''>SELECT DAY</option>";
for($i=1;$i<=31;$i++)
{
	$l_html.="<option value='$i'";
	if($_REQUEST["day"]==$i)
	{
		$l_html.=" selected";
	}
	$l_html.=">$i</option>";
}
$l_html.="</select>";
$l_html.="<input style='font:9px verdana;' name='fetch' type='submit' value='Go'>";
$l_html.="</form>";
if(!empty($_REQUEST["fetch"]) && !empty($_REQUEST["rhost"]) && !empty($_REQUEST["day"]))
{
	$l_polled=$l_poller->poll($_REQUEST["rhost"],$_REQUEST["day"]);
	if($l_polled)
	{
		foreach($l_poller->units as $l_metric => $l_units)
		{
			$l_html.="<br><img src='graph/".$_REQUEST["rhost"]."/$l_metric.gif'>";
		}
	}
}
$l_html.="</body></html>";
echo $l_html;
?>
Return current item: rrd4sar