Jump to content

Server Status display wizardry


redrat

Recommended Posts

good to know. I must be overlooking, or fat fingering something at this point. Been sitting in front of this screen for nearly 16 hours now ... time for a little rest. Will look this afternoon.

 

fixed it .. not sure what the issue was, I ended up blowing the 'portal' serverstatus.tpl file away & copying the 'default' moded version of it.

Link to comment
Share on other sites

  • Replies 148
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • 2 weeks later...

Okay, so I tried to make the server status wizardry work.

 

So far... I've managed to get this to work.

 

Unfortunately, however, I cannot get the server statuses to show... which is infuriating me. :|

 

NOTE: This is purely alpha stage. I am nowhere near ready to offering hosting to potential customers, as I'd prefer to get stuff working BEFORE customers start complaining that things are broken and/or not working.

 

Screenshot:

 

http://i37.photobucket.com/albums/e72/LitomoSilver/screenshot.jpg

Link to comment
Share on other sites

Firstly, please check that you have correctly configured your server in WHMCS Setup>Servers.

 

There must be one that is set up as the default server. To do that, simply click on the server entry at which point it will be given an asterisk (*) to indicate that it is the default server. EG: "Yourservername*" Please try this initially and post back with the results.

Link to comment
Share on other sites

Firstly, please check that you have correctly configured your server in WHMCS Setup>Servers.

 

There must be one that is set up as the default server. To do that, simply click on the server entry at which point it will be given an asterisk (*) to indicate that it is the default server. EG: "Yourservername*" Please try this initially and post back with the results.

 

... D'OH!

 

It works immediately the moment I did that.

 

Of course, I overlooked something stupid simple. =/

 

Thanks for that!

Link to comment
Share on other sites

Just had a thought...

 

If you're going to add multiple servers, how would you get them to show up on the status page?

They show up automatically as long as they are set up in WHMCS. Better still, only the servers that clients have active accounts on show up, not 'all' of your servers.

 

Pretty handy for some smaller hosts. ;)

Link to comment
Share on other sites

  • 4 weeks later...
They show up automatically as long as they are set up in WHMCS. Better still, only the servers that clients have active accounts on show up, not 'all' of your servers.

 

Pretty handy for some smaller hosts. ;)

 

Okay, so I added a test VM server hosting cPanel WHM.

 

Now... I've got it to show correctly, however, why the WHM image shows as unavailable and why the SMTP image is broken, I've absolutely no clue.

 

Here's a screenshot:

 

oddimage.jpg

 

How do I fix that? I've made sure that the /status/ is at the root of the server's setup.

Link to comment
Share on other sites

The SMTP images code at line 117 approx should read as follows in /whmcs/templates/yourtemplate/serverstatus.tpl

//SMTP

$port = 25;

 

$fp = fsockopen($host,$port,$errno,$errstr,10);

if(!$fp)

{

echo "<td><img src=\"images/statusfailed.gif\"></td>";

 

 

}else{

echo "<td><img src=\"images/statusok.gif\"></td>";

 

fclose($fp);

}

$this->assign('serverid',$serverid);

$this->assign('servername',$servername);

That will fix the missing image. The WHM warning is a different issue and possibly beyond my ability to help you with. WHM is certainly showing as down and that is the key to fixing this. Have you set this server up correctly in WHMCS with the correct user name and password or access hash? Best wishes. Edited by redrat
Link to comment
Share on other sites

The SMTP images code at line 117 approx should read as follows in /whmcs/templates/yourtemplate/serverstatus.tplThat will fix the missing image. The WHM warning is a different issue and possibly beyond my ability to help you with. WHM is certainly showing as down and that is the key to fixing this. Have you set this server up correctly in WHMCS with the correct user name and password or access hash? Best wishes.

 

The WHM is operating just fine.

 

I'm not entirely sure as to why it shows as down... but it is up.

 

I'll check the image code and see what's up.

 

Edit: Sure enough, the code fix you provided works. :D

 

Now it shows both WHM and SMTP as down... not entirely sure why yet. I'll check the ports.

Edited by Keiro
Link to comment
Share on other sites

Oh well... it seems that the serverstatus.tpl file is correct.

 

Now, how do I edit the tpl file so that it also checks for port 26 on the SMTP checking?

Try overwriting your whole /whmcs/templates/yourtemplate/serverstatus.tpl code with this but note the port references and change if necessary. (See end of this post for the locations of the WHM and SMTP ports.)
{if $loggedin}
<table  width="100%" class="clientareatable" align="center" cellspacing="1">
<tr class="clientareatableheading">
<td>{$LANG.servername}</td>
<td>Hosting</td>
<td>HTTP</td>
<td>WHM</td>
<td>CPanel</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> </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td><img src=\"images/statusfailed.gif\"></td>";
}

else{
echo "<tr class=\"clientareatableactive\">";
echo "<td>".$servername." </td>";
echo "<td>" .$hosteddomains."</td>";
echo "<td><img src=\"images/statusok.gif\"></td>";
fclose($fp);
}

//CPanel
$port = 2082;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//WHM
$port = 2086;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//FTP
$port = 21;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//POP3
$port = 110;

$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}

//SMTP
[size=3]$port = 25;[/size]
$fp = fsockopen($host,$port,$errno,$errstr,10);
if(!$fp)
{
echo "<td><img src=\"images/statusfailed.gif\"></td>";


}else{
echo "<td><img src=\"images/statusok.gif\"></td>";

fclose($fp);
}
$this->assign('serverid',$serverid);
$this->assign('servername',$servername);

{/php}

{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}

Note that this code uses port 25 for SMTP. See line 118.

WHM uses port 2086. See line 73. Check with your provider for the correct ports to use.

 

When you have set your ports correctly, find /whmcs/templates_c and delete the entire contents. It's just a cache. You should also delete your browser cache.

 

Best wishes.

Edited by redrat
Link to comment
Share on other sites

Try overwriting your whole /whmcs/templates/yourtemplate/serverstatus.tpl code with this but note the port references and change if necessary. (See end of this post for the locations of the WHM and SMTP ports.)

 

Note that this code uses port 25 for SMTP. See line 118.

WHM uses port 2086. See line 73. Check with your provider for the correct ports to use.

 

When you have set your ports correctly, find /whmcs/templates_c and delete the entire contents. It's just a cache. You should also delete your browser cache.

 

Best wishes.

 

... So I checked my VM for the ports.

 

It appears that my VM uses port 2087 for WHM.

 

I'm not entirely sure what port it uses for SMTP... but how do I get the status code to check for port 2086 then 2087, if the first port fails to respond?

 

And likewise, for port 25 and port 26?

Link to comment
Share on other sites

I think maybe you might be making this more complex than is necessary. Surely, you just ask your provider to let you know what the correct ports are for each and enter them in the /serverstatus.tpl where appropriate? It's also much faster to keep the script lean and mean. As you've already established what port WHM uses you just need to know the one that SMTP uses. :)

Link to comment
Share on other sites

It works just fine... if I use 2086 or 2087. I'm just mystified as to why it refuses to show the WHM and SMTP as up. I think I'll use GRC's portchecker program.

 

Actually, it's on my local machine. On my Virtual Machine, here.

 

It works on my provider's machine, and as to why it works, but not on the VM, I'm not entirely sure.

 

Edit: I deleted templates_c and it appears to not be working, either way.

 

Hmm. Any other possible clues?

Edited by Keiro
Missed Redrat's post and edited.
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
Care to share the code? I like the way you setup that status.

 

Finally i figured this out. You can use the original status/index.php with method.

 

Please note two things,

1. I'm using DA instead of cPanel/WHM hence 'DAPanel'.

2. I'm using a firewall which blocks port 3306 from outside. I don't know a workaround on this. Sorry :(

 

 

<p>{$LANG.serverstatusheadingtext}</p>
<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0" class="data">
 <tr align="center">
   <th>{$LANG.servername}</th>
   <th>DAPanel</th>
   <th>HTTP</th>
   <th>MySQL</th>
   <th>FTP</th>
   <th>POP3</th>
   <th>SMTP</th>
   <th>{$LANG.serverstatusphpver}</th>
   <th>{$LANG.serverstatusmysqlver}</th>
   <th>{$LANG.serverstatusserverload}</th>
   <th>{$LANG.serverstatusuptime}</th>
 </tr>
 {foreach key=num item=server from=$servers}
 <tr align="center">
   <td>{$server.name}</td>
   <td>{get_port_status num="$num" port="2222"}</td>
   <td>{get_port_status num="$num" port="80"}</td>
   <td>{get_port_status num="$num" port="3306"}</td>
   <td>{get_port_status num="$num" port="21"}</td>
   <td>{get_port_status num="$num" port="110"}</td>
   <td>{get_port_status num="$num" port="25"}</td>
   <td>{$server.phpver}</td>
   <td>{$server.mysqlver}</td>
   <td>{$server.serverload}</td>
   <td>{$server.uptime}</td>
 </tr>
 {foreachelse}
 <tr>
   <td colspan="7">{$LANG.serverstatusnoservers}</td>
 </tr>
 {/foreach}
</table>

 

I think you can also use $server.zendver to get zend version also. And please note you need to manually edit the languages files if you want to include {$LANG.serverstatusmysqlver} etc.

srvstatus.jpg

Link to comment
Share on other sites

That's neat but it is not within the design criteria of the original modification which was to expressly leave the server load and uptime out. It's easy enough just to remove those two lines of code though and I like the addition of the PHP and MySQL versions. Nice touch.

 

It's also a nice touch to have added the http and ping stats. How are you achieving that?

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