| Site Maintenance Program updates, securing your website, creating backups. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
|
|
#1 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Mar 2006
Hosted on SH100
458 posts
Gave thanks: 75
Thanked 17 times
|
I use the following server status script to monitor my websites on a shared server here. I don't know where I originally got it but it works really well. Until now
![]() Code:
<?php
/*
* +------------------------------------------------------------------------------+
* CPANEL STATUS SCRIPT
* +------------------------------------------------------------------------------+
* Copyright Notice(s)
* +------------------------------------------------------------------------------+
* Disclaimer Notice(s)
* ex: This code is freely given to you and given "AS IS", SO if it damages
* your computer, formats your HDs, or burns your house I am not the one to
* blame.
* Moreover, don't forget to include my copyright notices and name.
* +------------------------------------------------------------------------------+
* Author(s): Crooty.co.uk (Adam C)
* +------------------------------------------------------------------------------+
*/
// Configure script
$timeout = 1;
// Set service checks
$port[1] = 80;
$service[1] = 'Apache';
$ip[1] = '';
$port[2] = 21;
$service[2] = 'FTP';
$ip[2] = '';
$port[3] = 3306;
$service[3] = 'MYSQL';
$ip[3] = '';
$port[4] = 25;
$service[4] = 'Email(POP3)';
$ip[4] = '';
$port[5] = 143;
$service[5] = 'Email(IMAP)';
$ip[5] = '';
$port[6] = 2095;
$service[6] = 'Webmail';
$ip[6] = '';
$port[7] = 2082;
$service[7] = 'Cpanel';
$ip[7] = '';
$port[8] = 80;
$service[8] = 'Internet Connection';
$ip[8] = 'google.com';
$port[9] = 2086;
$service[9] = 'WHM';
$ip[9] = '';
//
// NO NEED TO EDIT BEYOND HERE UNLESS YOU WISH TO CHANGE STYLE OF RESULTS
//
?>
<html>
<head>
<title>Service Status</title>
<style type="text/css">
<!--
td, body
{
font-family: Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #444444;
}
.status_header
{
border-bottom: 1px solid #999999;
width: 480;
color: #3896CC;
}
.status_table
{
border: 1px solid #333333;
border-collapse: collapse;
width: 480;
}
td
{
border: 1px solid #333333;
}
.online
{
background-color: #D9FFB3
}
.offline
{
background-color: #FFC6C6;
}
-->
</style>
</head>
<body>
<br />
<center>
<div class="status_header"><strong>Service Status</strong></div>
</center>
<br />
<table class="status_table" cellspacing="0" cellpadding="3" align="center">
<?php
// Count arrays
$ports = count($port) + 1;
$count = 1;
while ($count < $ports)
{
if ($ip[$count] == '')
{
$ip[$count] = 'localhost';
}
$fp = @fsockopen($ip[$count], $port[$count], $errno, $errstr, $timeout);
if (!$fp)
{
echo "<tr>\n <td>{$service[$count]}</td>\n <td class=\"offline\">Offline</td>\n</tr>\n";
fclose($fp);
}
else
{
echo "<tr>\n <td>{$service[$count]}</td>\n <td class=\"online\">Online</td>\n</tr>\n";
fclose($fp);
}
$count++;
}
//
// SERVER INFORMATION
//
?>
</table>
<br />
<center>
<div class="status_header"><strong>Server Information</strong></div>
</center>
<br />
<table class="status_table" cellspacing="0" cellpadding="3" align="center">
<?php
// GET SERVER LOADS
$loadresult = @exec('uptime');
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $loadresult, $avgs);
// GET SERVER UPTIME
$uptime = explode(' up ', $loadresult);
$uptime = explode(',', $uptime[1]);
$uptime = $uptime[0] . ', ' . $uptime[1];
echo "<tr>\n <td>Server Load Averages</td>\n <td>$avgs[1], $avgs[2], $avgs[3]</td>\n</tr>\n<tr>\n <td>Server Uptime</td>\n <td>$uptime</td>\n</tr>\n";
?>
</table>
</body>
</html>
http://www.usasentinel.com/status.php Notice at the bottom that the server information section is blank. On my other 2 servers it shows the correct info. Does anyone have any ideas as to why this is not working with sh131 when it is working fine with sh100 and sh124?
__________________
SH100 , SH131 & SH124 |
|
|
|
|
|
#2 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
|
Something tells me $loadresult =
exec('uptime'); is failing. You might remove the " " in front of exec so that it will echo any warnings or errors. It's also possible that the exec() function was/is disabled on that server.
__________________
|
|
|
|
| This user thanks MarkRH for this great post! | Sentinel (December 3rd, 2007) |
|
|
#5 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Mar 2006
Hosted on SH100
458 posts
Gave thanks: 75
Thanked 17 times
|
Sorry it took me so long to reply.
Yes, that did the trick. I mean it did not fix it but I don't think your intention was to fix it but to help me find out what was wrong, and removing the " " symbol from that line resulted in the following error code...Code:
Warning: exec() has been disabled for security reasons in /home/myusername/public_html/status.php on line 164 ) is disabled. I don't know why ... mainly because I don't know what it does Does disabling/enabling it have anything to do with the security of the server? Is it off by default?
__________________
SH100 , SH131 & SH124 |
|
|
|
|
|
#6 (permalink) |
|
Surpass Fan
On a golden path...
Joined in Mar 2006
Hosted on SH100
458 posts
Gave thanks: 75
Thanked 17 times
|
Surpass has enabled it for me and I love this place and these guys are great. But you know what? I just asked them to change it back. Apparently this thing is a security feature and should be off by default. If that's so then I don't want to be the cause of it being on just for a dopey script. This script doesn't mean that much to me to lessen security on the server.
For me security is king. Yes, I am the kind of guy that locks my car in the garage ![]()
__________________
SH100 , SH131 & SH124 |
|
|
|
|
|
#7 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
|
Well, for Gallery2 to use ImageMagick to process images, it has to be on since it uses a command line interface with the convert executable. Of course, you can always use PHP's GD instead, but ImageMagick does seem to create slightly better looking images.
__________________
|
|
|
|
|
|
#8 (permalink) |
|
Operations
Super #1
Joined in Jun 2005
Lives in surpass headquarters
1,028 posts
Gave thanks: 67
Thanked 127 times
|
the exec() php option is disabled by default on newer servers as a security precaution. So adding a local php.ini and removing exec from disabled functions is the workaround.
Sentinel, if you still want to use the status script you can place the script file and the php.ini I created for you in a sub folder instead of in public_html root. This would almost eliminate the security risk.
__________________
Mike Surpass Special Operations |
|
|
|
|
|
#9 (permalink) |
|
Race Surpass
Super #1
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
|
Hmmm... I may have do that to explicitly disable that function where I want. Hopefully php has been configured on his server to recognize local php.ini files.
Edit: Actually, I just realized that this is what I've been doing. These functions are disabled by default with PHP5 on my server: exec, shellexec, passthru, system, escapeshellcmd, I've just been using my own php.ini the whole time which doesn't disable them. However, they were all disabled on my companyofvalor domain as it's using the default config. I need to put my own php.ini in there as the server actually has allow_url_fopen on by default.
__________________
|
|
|
|