Jump to content

Customized Server Status


arteryplanet

Recommended Posts

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Ok i have a fix for you guys who are having problems with the "NOT OK" ok the script he wrote reads from the server name from within whmcs most likely you dont have the server name to the actually host name for example

 

you might have it set as "Server 1"

to make the script work you have to make the name of the server config in whmcs the quailified domain name for instance:

"server1.domain.net"

That's it. I did this:

 

around line 23 change:

$servername = $row2['name'];

to

$servername = $hosteddomain;

 

Seems to work. Thanks gasmoney ... :)

Link to comment
Share on other sites

That's it. I did this:

 

around line 23 change:

$servername = $row2['name'];

to

$servername = $hosteddomain;

 

Seems to work. Thanks gasmoney ... :)

 

No problem ..

Also the way you put the code it actually uses the domain of the user logged in so my adivce would be to use the servers ip address which can be called like this.

 

$servername = $row2['name'];

to

$servername = $row2['ipaddress'];

 

This will actually check the whole server in general instead of putting the customers hosted domain in the field

Link to comment
Share on other sites

Hi gasmoney, sure go ahead you have permission. Sorry guys but im not an expert in php.

Something to keep in mind gasmoney is the code do not work when is a dedi server plan, will be great if you could get the mysql query to check this first and then find a way to add the dedi server hostname instead the shared server hostname, i wasnt able to do this because the dedi servers info is in another table and not in the same as the shared hosting one.

 

Thanx!

Link to comment
Share on other sites

Ok yea ill probably add dedicated support and a option in the admin panel to add extra ports that you want to monitor. Any other ideas? Make it dynamic

Minor, but maybe separate the the single column "(<domain-name>) - serverIP" into two columns.

Link to comment
Share on other sites

Add an IF statement and then see if you can find the dedicated server's IP, else print the shared hosting's monitor.

 

Is not that simple, dedicated servers information is not in the same table than the shared one.

 

Anyway, i guess with a good php/mysql knowledge that is not a problem.

Link to comment
Share on other sites

  • 2 weeks later...

I Like this.

Portal Templates Folder/serverstatus.tpl

See attached image.

 

{if $loggedin}
<table class="clientareatable" align="center" cellspacing="1">
 <tr class="clientareatableheading">
   <td>{$LANG.servername}</td>
   <td>HTTP</td>
   <td>FTP</td>
   <td>POP3</td>
   <td><div align="center">WEBMAIL</div></td>
   <td>SMTP</td>
   <td><div align="center">DNS</div></td>
   <td><div align="center">cPanel</div></td>
   <td><div align="center">{$LANG.serverstatusuptime}</div></td>
 </tr>
 {foreach key=num item=server from=$servers}
 <tr class="clientareatableactive">
   <td>{$server.name}</td>
   <td>{get_port_status num="$num" port="80"}</td>
   <td>{get_port_status num="$num" port="21"}</td>
   <td>{get_port_status num="$num" port="110"}</td>
   <td><div align="center">{get_port_status num="$num" port="2095"}</div></td>
   <td>{get_port_status num="$num" port="25"}</td>
   <td><div align="center">{get_port_status num="$num" port="53"}</div></td>
   <td><div align="center">{get_port_status num="$num" port="2083"}</div></td>
   <td><div align="center">{$server.uptime}</div></td>
 </tr>
 {foreachelse}
 <tr class="clientareatableactive">
   <td colspan="9">{$LANG.serverstatusnoservers}</td>
 </tr>
 {/foreach}
</table>
{else}
<p>{$LANG.loginintrotext}</p>

<form action="dologin.php?goto=serverstatus" method="post">

<table align="center">
<tr><td align="right">{$LANG.loginemail}:</td><td><input type="text" name="username" size="40" value="{$username}"></td></tr>
<tr><td align="right">{$LANG.loginpassword}:</td><td><input type="password" name="password" size="25" value="{$password}"></td></tr>
</table>

<p align="center"><input type="submit" value="{$LANG.loginbutton}"><br><input type="checkbox" name="rememberme"{$rememberme}> {$LANG.loginrememberme}</p>
</form>
<p><b>{$LANG.loginforgotten}</B> <a href="passwordreminder.php">{$LANG.loginforgotteninstructions}</a>.</p>
{/if}

image.jpg

Link to comment
Share on other sites

I like it! There were a few things I wanted done differently, namely a single call to each server to check status as opposed to multiple if the customer had more than one domain on a single server. I also have some services which I do not track the status of ... I could make another slight change to just exclude them from the status listing - but then, customers may wonder why that domain is missing.

 

Anywho, here's my slightly modified version...

 

serverstatus1.gif

 

The only thing different since this screenshot is the list is now sorted alphabetically by server name (so Server 1, Server 2, etc. instead of Server 5, Server 3...)

 

{if $loggedin}
<table class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>Hosting</td>
<td>HTTP</td>
<td>FTP</td>
<td>POP3</td>
<td>SMTP</td>
</tr>
<tr>
{php}
$query1 = "SELECT * FROM tblservers ORDER BY name";
$result1 = mysql_query($query1);
while ($row1 = mysql_fetch_array($result1)) {

$serverid = $row1['id'];
$servername = $row1['name'];
$host = $row1['ipaddress'];

$hosteddomains="";

$query2 = "SELECT * FROM tblhosting WHERE userid='".$_SESSION["uid"]."' AND domainstatus='Active' AND server='".$serverid."'";

$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_array($result2)) {

$hosteddomain = $row2['domain'];
$hosteddomains.=$hosteddomain."<br>";
}
if ($hosteddomains) {
$hosteddomains=substr($hosteddomains,0,-4);

if ($host) {
//HTTP
$port = 80;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<tr class=\"clientareatableactive\">";
echo "<td><b>".$servername."</b> [".$host."]</td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td rowspan=\"2\"><strong><font color=\"#FF0000\">Not OK</font></strong></td>";
}

else{
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername." [".$host."]</td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td rowspan=\"2\"><strong>OK</strong></td>";
fclose($fp);
}

//FTP
$port = 21;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><strong><font color=\"#FF0000\">Not OK</font></strong></td>";


}else{
echo "<td rowspan=\"2\"><strong>OK</strong></td>";

fclose($fp);
}

//POP3
$port = 110;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><strong><font color=\"#FF0000\">Not OK</font></strong></td>";


}else{
echo "<td rowspan=\"2\"><strong>OK</strong></td>";

fclose($fp);
}

//SMTP
$port = 25;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td rowspan=\"2\"><strong><font color=\"#FF0000\">Not OK</font></strong></td><tr>";


}else{
echo "<td rowspan=\"2\"><strong>OK</strong></td></tr>";

fclose($fp);
}
$this->assign('serverid',$serverid);
$this->assign('servername',$servername);
echo "<tr class=\"clientareatablepending\">";
echo "<td colspan=\"2\">";
{/php}
{foreach key=num item=server from=$servers}
{if $server.name == $servername}
<b>Uptime:</b> {$server.uptime}
 - 
<b>Load Average:</b> {$server.serverload}<br>
{/if}
{/foreach}
{php}
echo "</td></tr>";
} else {
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername."</td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td colspan=\"5\"><strong><font color=\"#AAAAAA\">Not Monitored Here</font></strong></td>";
}}}
{/php}
</table>
{else}
<p>{$LANG.loginintrotext}</p>

<form action="dologin.php?goto=serverstatus" method="post">

<table align="center">
<tr><td align="right">{$LANG.loginemail}:</td><td><input type="text" name="username" size="40" value="{$username}"></td></tr>
<tr><td align="right">{$LANG.loginpassword}:</td><td><input type="password" name="password" size="25" value="{$password}"></td></tr>
</table>

<p align="center"><input type="submit" value="{$LANG.loginbutton}"><br><input type="checkbox" name="rememberme"{$rememberme}> {$LANG.loginrememberme}</p>
</form>
<p><b>{$LANG.loginforgotten}</B> <a href="passwordreminder.php">{$LANG.loginforgotteninstructions}</a>.</p>
{/if}

Link to comment
Share on other sites

I know I had troubles getting this to work on mine. I went ahead and modified it to my needs. It shows the standard Server Stats along with a login form. If you are logged in, it shows you standard stats plus detailed stats for each domain.

{if $loggedin}
<p>{$LANG.serverstatusheadingtext}</p>
<table class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>HTTP</td>
<td>FTP</td>
<td>POP3</td>
<td>{$LANG.serverstatusphpinfo}</td>
<td>{$LANG.serverstatusserverload}</td>
<td>{$LANG.serverstatusuptime}</td>
</tr>
{foreach key=num item=server from=$servers}
<tr class="clientareatableactive">
<td>{$server.name}</td>
<td>{get_port_status num="$num" port="80"}</td>
<td>{get_port_status num="$num" port="21"}</td>
<td>{get_port_status num="$num" port="110"}</td>
<td><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
<td>{$server.serverload}</td>
<td>{$server.uptime}</td>
</tr>
{foreachelse}
<tr class="clientareatableactive">
<td colspan="7">{$LANG.serverstatusnoservers}</td>
</tr>
{/foreach}
</table>
<p>The table below shows the status of your domains and which server they are hosted on.</p>
<table class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>HTTP</td>
<td>HTTPS</td>
<td>FTP</td>
<td>POP3</td>
<td>SMTP</td>
<td>IMAP</td>
</tr>
<tr>
{php}
//echo "<pre>";
//print_r($_SESSION);
//echo "</pre>";
$query = "SELECT * FROM tblhosting WHERE userid='".$_SESSION["uid"]."' AND domainstatus='Active'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) 
{
//	echo "<pre>";
//	print_r($row);
//	echo "</pre>";

$activeserver = $row['server'];
$hosteddomain = $row['domain'];

$query2 = "SELECT * FROM tblservers WHERE id='".$activeserver."'";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2);

//	echo "<pre>";
//	print_r($row2);
//	echo "</pre>";

//HTTP
$fp = fsockopen($row['domain'],80,$errno,$errstr,10);
if(!$fp)
{
	echo '<tr class="clientareatableactive">';
	echo "<td>( " .$row['domain']. " ) - " .$row2['name']."</td>";
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<tr class=\"clientareatableactive\">";
	echo "<td>( " .$row['domain']. " ) - " .$row2['name']."</td>";
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}
//SSL
$fp = fsockopen('ssl://'.$row['domain'],443,$errno,$errstr,10);
if(!$fp)
{
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}

//FTP
$fp = fsockopen($row['domain'],21,$errno,$errstr,10);
if(!$fp)
{
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}

//POP3
$fp = fsockopen($row['domain'],110,$errno,$errstr,10);
if(!$fp)
{
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}

//SMTP
$fp = fsockopen($row['domain'],25,$errno,$errstr,10);
if(!$fp)
{
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}

//IMAP
$fp = fsockopen($row['domain'],143,$errno,$errstr,10);
if(!$fp)
{
	echo "<td><img src=\"images/status/ball_red.gif\"></td>";
}else{
	echo "<td><img src=\"images/status/ball_green.gif\"></td>";
	fclose($fp);
}
}
{/php}
</tr>
</table>
{else}
<p>{$LANG.serverstatusheadingtext}</p>

<table class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>HTTP</td>
<td>FTP</td>
<td>POP3</td>
<td>{$LANG.serverstatusphpinfo}</td>
<td>{$LANG.serverstatusserverload}</td>
<td>{$LANG.serverstatusuptime}</td>
</tr>
{foreach key=num item=server from=$servers}
<tr class="clientareatableactive">
<td>{$server.name}</td>
<td>{get_port_status num="$num" port="80"}</td>
<td>{get_port_status num="$num" port="21"}</td>
<td>{get_port_status num="$num" port="110"}</td>
<td><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
<td>{$server.serverload}</td>
<td>{$server.uptime}</td>
</tr>
{foreachelse}
<tr class="clientareatableactive">
<td colspan="7">{$LANG.serverstatusnoservers}</td>
</tr>
{/foreach}
</table>
<p>You must login to view detailed Server Statistics!  These login details differ from your websites control panel username and password.
</p>

<form action="dologin.php?goto=serverstatus" method="post">

<table align="center">
<tr><td align="right">{$LANG.loginemail}:</td><td><input type="text" name="username" size="40" value="{$username}"></td></tr>
<tr><td align="right">{$LANG.loginpassword}:</td><td><input type="password" name="password" size="25" value="{$password}"></td></tr>
</table>

<p align="center"><input type="submit" value="{$LANG.loginbutton}"><br><input type="checkbox" name="rememberme"{$rememberme}> {$LANG.loginrememberme}</p>
</form>
<p><b>{$LANG.loginforgotten}</B> <a href="passwordreminder.php">{$LANG.loginforgotteninstructions}</a>.</p>
{/if}

 

 

Preview Not Logged In:

notloggedin.jpg

 

 

Preview Logged In:

loggedin.jpg

Link to comment
Share on other sites

I wanna be a baller and have 13 servers. :(

 

hahaha. That is a list of domains. Sadly I only have the one server for now. One thing to note is that it will show all of your servers in the top table and then list the domains and what server they are on in the second table. Obviously it is user based.

Link to comment
Share on other sites

Just to clarify, when the user is not logged in, this is showing the server status on all servers.

 

We currently have just over 120 servers in operation, so we don't display status of ALL servers to ALL users, and only want to display the individual servers for whatever an account may be hosted on.

 

Any thoughts?

Link to comment
Share on other sites

handsonwebhosting will be great if you add what s1rk3ls did above, show as many as domains/accounts the user have on each server instead to show different fields for the same server with different domains if the client have more than 1 account in the same server.

 

Thanx!

Link to comment
Share on other sites

Just to clarify Arteryplanet - I think this was supposed to be addressed to "tsiedsma". Personally, I've not made any modifications to the code and posted them here - mine was just a thought process on the expandability, so the credit goes to the other programmers that have posted here thus far. All postings have been great improvements, and I look forward to seeing more!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated