Hello everyone
I have a very simple php page that uses shell_exec to get some basic stats for my LAMP. I currently have it setup to where it uses a javascript refresh every 60 seconds, but would like to setup AJAX to have it so it doesnt actually refresh the page. I am new to javascript/ajax so I am a little lost, here is my code
[CODE]<html>
<title> System Stats </title>
<head>
<script type=”text/JavaScript”>
function timedRefresh(timeoutPeriod) {
setTimeout(“location.reload(true);”,timeoutPeriod);
}
</script>
</head>
<body onload=”JavaScript:timedRefresh(60000);”>
<?php
/* Here I am setting up the variables for the commands to pass down through to the shell */
$top = (shell_exec(“top -b | head -n 25”));
$stats = (shell_exec(“iostat”));
$uptime = (shell_exec(“uptime”));
$disk = (shell_exec(“df -h”));
$lastlog = (shell_exec(“lastlog | grep -v ‘*'”));
$dmesg = (shell_exec(“dmesg | tail -n 25”));
/* Here I am outputting to the screen the commands I have specified above*/
echo “<BR><font color=green size=7> First 25 lines of top</font>n “;
echo “<pre><font color=black>$top</font></pre>”;
echo “<BR><font color=green size=7> Last 25 lines of dmesg</font>n “;
echo “<pre><font color=black>$dmesg</font></pre>”;
echo “<font color=green size=7>I/O stats</font>n”;
echo “<pre><font color=black>$stats</font></pre>”;
echo “<BR><font color=green size=7>Disk usage</font>n”;
echo “<pre><font color=black>$disk</font></pre>”;
echo “<BR><font color=green size=7> Last login info </font>n”;
echo “<pre><font color=black>$lastlog</font></pre>”;
echo “<BR><BR><BR>”;
?>
</body>
</html>
I have been reading lots of blog/forums about this topic but I think I am just being overwhelmed with information. Any help would be appreciated. Thank!!!