Server Status
Submitted by deconectat on Tue, 03/03/2009 - 17:47
Hi,
I edited the serverStatus function to display some useful information. I know the links to start/stop/restart services don't work yet, but I don't know how to make them work.
I attached the modified function and a screenshot.
LE: I also added a link to server status in the template (under system).
Attachment | Size |
---|---|
![]() | 3.12 KB |
![]() | 56.55 KB |
ehcpdeveloper
Tue, 03/03/2009 - 18:13
Permalink
thank you for file, i will
thank you for file, i will check and include in ehcp
i will merge with some functions that i wrote too..
you are a great ehcp man ! :)
ehcpdeveloper
Sat, 03/07/2009 - 23:23
Permalink
function
function serverStatus(){
$this->requireAdmin();
//-------------- deconectat edit ---------------------------------------------------------
$this->output.="<div class='footer'><table> ";
$this->output.="<tr><td>Apache2: </td><td>";
$serviceCount=$this->executeProg3("ps ax | grep /apache2 | grep -v grep | wc -l");
if ($serviceCount > 0) $this->output.="<font color='#00cc00'><strong>YES</strong></font>";
else $this->output.="<font color='#ff0000'><strong>NO</strong></font>";
$this->output.="</td><td> (<a href='?op=startapache2'>Start</a> | <a href='?op=stopapache2'>Stop</a> | <a href='?op=restartapache2'>Restart</a>)</td></tr>";
$this->output.="<tr><td>MySQL: </td><td>";
$serviceCount=$this->executeProg3("ps ax | grep '/mysqld ' | grep -v grep | wc -l");
if ($serviceCount > 0) $this->output.="<font color='#00cc00'><strong>YES</strong></font>";
else $this->output.="<font color='#ff0000'><strong>NO</strong></font>";
$this->output.="</td><td> (<a href='?op=startmysql'>Start</a> | <a href='?op=stopmysql'>Stop</a> | <a href='?op=restartmysql'>Restart</a>)</td></tr>";
$this->output.="<tr><td>Vsftpd: </td><td>";
$serviceCount=$this->executeProg3("ps ax | grep vsftpd | grep -v grep | wc -l");
if ($serviceCount > 0) $this->output.="<font color='#00cc00'><strong>YES</strong></font>";
else $this->output.="<font color='#ff0000'><strong>NO</strong></font>";
$this->output.="</td><td> (<a href='?op=startvsftpd'>Start</a> | <a href='?op=stopvsftpd'>Stop</a> | <a href='?op=restartvsftpd'>Restart</a>)</td></tr>";
$this->output.="<tr><td>Bind: </td><td>";
$serviceCount=$this->executeProg3("ps ax | grep bind | grep -v grep | wc -l");
if ($serviceCount > 0) $this->output.="<font color='#00cc00'><strong>YES</strong></font>";
else $this->output.="<font color='#ff0000'><strong>NO</strong></font>";
$this->output.="</td><td> (<a href='?op=startvsftpd'>Start</a> | <a href='?op=stopvsftpd'>Stop</a> | <a href='?op=restartvsftpd'>Restart</a>)</td></tr>";
$this->output.="</table></div> ";
# i edited this part a bit, ehcpdeveloper
$systemStatus="\n Memory: used free (MB)\n".$this->executeProg3("free -m | grep buffers/ca | cut -d\":\" -f2")."\n--------------------------------------------------------------------------\n";
$systemStatus.="\ndf -h\n".$this->executeProg3("df -h")."\n--------------------------------------------------------------------------\n";
$systemStatus.="\nUptime:\n".$this->executeProg3("uptime");
$systemStatus.="\nhosts.deny:\n".$this->executeProg3("cat /etc/hosts.deny");
$systemStatus.="\nnetstat -anp | grep tcp:\n".$this->executeProg3("netstat -anp | grep tcp");
$this->output.="<div class=\"footer\"><pre>".$systemStatus."</pre></div>";
//-------------- end deconectat edit -----------------------------------------------------
$topoutput=$this->executeProg3("top -b -n 1 | head -40");
$this->output.="<hr><div align=left>Top output: <br> <pre>$topoutput</pre></div>";
$topoutput=$this->executeProg3("tail -100 /var/log/syslog");
$this->output.="<hr><div align=left>Syslog (to see this, you must chmod a+r /var/log/syslog on server console): <br> <pre>$topoutput</pre></div>";
return true;
}
deconectat
Tue, 03/17/2009 - 23:12
Permalink
I added some more info in the
I added some more info in the server status (hostname, kernel version, php, mysql and apache version):
$systemStatus=$this->executeProg3("
echo \"\";
echo \"==========================================================================\";
echo -n \"Hostname: \";
hostname;
uname -srm;
echo \"\"
echo -n \"PHP version: \";
/usr/bin/php -nv | grep built | cut -d \" \" -f2;
echo -n \"MySQL version: \";
/usr/bin/mysql -V | cut -d \" \" -f6 | cut -d \",\" -f1;
echo -n \"Apache version: \";
/usr/sbin/apache2 -v | grep version | cut -d \"/\" -f2;
echo \"--------------------------------------------------------------------------\";
echo \"Memory: used free (MB)\" ...