redrat Posted September 11, 2008 Share Posted September 11, 2008 Good morning. OK, I've been playing around with the whole Server Status display conundrum from a 'one-server host provider perspective' and have made a very useful discovery that is an ideal solution for me atm and may well be for others in a similar position. Client Area Objectives 1. Server Status only available when logged in so no public access other than that whatsoever. 2. When logged in display meaningful and useful indicators to clients. 3. Only to display information relevant to the server clients are actually hosted on. 4. Not to display text such as, "The table below shows the status of our server. You can use this page to check if any of the services on our servers are down.", above the display. This is because it then makes it obvious that I only have one server and that is not what I want to present as it causes unnecessary concern about how 'big' my operation is and that is not desirable from a marketing point of view. 5. Not to display the phpinfo link. a) It mentions "Linux Notmy.serverserver.com 2.6.18-53.el5 #1 SMP Mon Nov 12 02:14:55 EST 2007 x86_6" right at the top and that makes for confusion and suspicion that, as well as having only one server, I am also very likely a reseller. b) I can easily provide all php information by other means with that reference removed. So, of all possibilities, this is what I want clients to see: and not this: or this: Clients can get a very good picture of what is happening with the server from cPanel anyway and the uptime information can be easily provided by other means. Admin Area objective 1. Very simply to be able to see all of the Server Status information that WHMCS is capable of displaying with no blank table cells. So I want to see this in my Admin Area: Well now I have exactly that so I thought I ought to share i with you guys. This is how it is achieved: Client Area: Overwrite your /WHMCS/templates/portal/serverstatus.tpl code with this code: {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 rowspan=\"2\"><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 rowspan=\"2\"><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 rowspan=\"2\"><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 rowspan=\"2\"><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 rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td>"; }else{ echo "<td><img src=\"images/statusok.gif\"></td>"; fclose($fp); } //SMTP $port = 25; $fp = fsockopen($host,$port,$errno,$errstr,10); if(!$fp) { echo "<td rowspan=\"2\"><img src=\"imagesfailed.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} Admin Area: Place the following code in a new file - /public_html/status/index.php <?php error_reporting(0); if (ini_get('disable_functions')) { $disabled_funcs=array_map('trim',explode(',',ini_get('disable_functions'))); } $action=$_GET["action"]; if ($action=="phpinfo") { phpinfo(); } else { $users[0]="Unavailable"; $users[1]="--"; $loadnow="Unavailable"; $load15="--"; $load30="--"; if (in_array('exec',$disabled_funcs)) { $load=file_get_contents("/proc/loadavg"); $load=explode(' ',$load); $loadnow=$load[0]; $load15=$load[1]; $load30=$load[2]; } else { $reguptime=trim(exec("uptime")); if ($reguptime) { if (preg_match("/, *(\d) (users?), .*: (.*), (.*), (.*)/",$reguptime,$uptime)) { $users[0]=$uptime[1]; $users[1]=$uptime[2]; $loadnow=$uptime[3]; $load15=$uptime[4]; $load30=$uptime[5]; } } } if (in_array('shell_exec',$disabled_funcs)) { $uptime_text=file_get_contents("/proc/uptime"); $uptime=substr($uptime_text,0,strpos($uptime_text," ")); } else { $uptime=shell_exec("cut -d. -f1 /proc/uptime"); } $days=floor($uptime/60/60/24); $hours=str_pad($uptime/60/60%24,2,"0",STR_PAD_LEFT); $mins=str_pad($uptime/60%60,2,"0",STR_PAD_LEFT); $secs=str_pad($uptime%60,2,"0",STR_PAD_LEFT); $phpver=phpversion(); $mysqlver=mysql_get_client_info(); $zendver=zend_version(); echo "<load>$loadnow</load>\n"; echo "<uptime>$days Days $hours:$mins:$secs</uptime>\n"; echo "<phpver>$phpver</phpver>\n"; echo "<mysqlver>$mysqlver</mysqlver>\n"; echo "<zendver>$zendver</zendver>\n"; } ?> Finally, there is just one important last thing you must do for this to work: In the Admin Configuration/Servers section @ http://yourdomain.com/whmcs/admin/configservers.php?action=edit&id=1 the URL you have to use as the Server Status Address is: http://yourdomain.com/status/ (with the trailing slash) Bob's your Uncle! It works like a dream. I am using the latest 3.7.1 but this will also work for 3.6.2 or so I believe. I have not tested the latter but can see no reason why not. Important It is a solution for which I have not written any code whatsoever and all credit goes to those who did. I just experimented a little and made my discovery purely by accident. Enjoy! 0 Quote Link to comment Share on other sites More sharing options...
KayoteX Posted September 11, 2008 Share Posted September 11, 2008 Thanks man! 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted September 12, 2008 Share Posted September 12, 2008 Cool. You just added port checking for the other services that most servers run, and took my modified status script 0 Quote Link to comment Share on other sites More sharing options...
jmanuel Posted September 12, 2008 Share Posted September 12, 2008 Thanks for your script! 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted September 13, 2008 Author Share Posted September 13, 2008 larwilliams:Thanks for your cool script. It solved a problem brilliantly. 0 Quote Link to comment Share on other sites More sharing options...
bogo Posted September 13, 2008 Share Posted September 13, 2008 Thank you Your Template have a error ? "Client Area: Overwrite your /WHMCS/templates/portal/serverstatus.tpl code with this code:" regards 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted September 13, 2008 Author Share Posted September 13, 2008 I'm not sure that is a script error or possibly something to do with your php settings? Unfortunately, as I did not write the script myself, I am unable to provide any support for it. But someone else might investigate this for you. 0 Quote Link to comment Share on other sites More sharing options...
bogo Posted September 13, 2008 Share Posted September 13, 2008 Hello, this failure is only more at 2 Status Lines. 1 Statusline is ok. regards 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted September 13, 2008 Author Share Posted September 13, 2008 It might be an idea to PM larwilliams to take a look at this for you as he seems to have his head around this issue coding wise. Although he did not write this particular script he might be willing to help resolve this? 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted September 13, 2008 Author Share Posted September 13, 2008 I meant to add the status script will check the logged in user and only display the server status of the servers you are hosted on. If you had multiple packages that were hosted on different servers, those servers and domains would be listed as well. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted September 15, 2008 Share Posted September 15, 2008 Well done boys. Just a tip, though. Rather than have the client run all over the site looking for infromation, why not drop a couple of includes into the client area home page to give them a summary. (Disclaimer:- this is great for small clients, but not so good for resellers or clients with hundreds of domains etc) eg. {include file='serverstatus.tpl'} {include file='upcomingdomainrenewal.tpl'} {include file='recentannouncements.tpl'} {include file='clientareanotes.tpl'} Plus a couple of other customs, as per the screenshot, notes, etc Drop in a couple of hyperlinks to the relevant sections, and you have a nice one page snapshot summary of the client. 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted September 15, 2008 Share Posted September 15, 2008 Well done boys. Just a tip, though. Rather than have the client run all over the site looking for infromation, why not drop a couple of includes into the client area home page to give them a summary. (Disclaimer:- this is great for small clients, but not so good for resellers or clients with hundreds of domains etc) eg. {include file='serverstatus.tpl'} {include file='upcomingdomainrenewal.tpl'} {include file='recentannouncements.tpl'} {include file='clientareanotes.tpl'} Plus a couple of other customs, as per the screenshot, notes, etc Drop in a couple of hyperlinks to the relevant sections, and you have a nice one page snapshot summary of the client. That's a cool idea. Is it really just as simple as including the tpl files on the page?? The problem with the messed up status display a few posts up is due to HTML i believe. Unfortunately, I did not make any changes to the output of the status script i modified, so I have no experience with it. 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted September 15, 2008 Author Share Posted September 15, 2008 @Zorro67 Very nice indeed. I shall definitely play around with this concept and see how I can improve the client area display page along the lines you have achieved and thanks for the contribution. @larwilliams Ah OK Lars but thanks for dropping by anyway. 0 Quote Link to comment Share on other sites More sharing options...
Zorro67 Posted September 16, 2008 Share Posted September 16, 2008 Sorry guys, a slight mis-type. I deleted my template name. the correct code should have been {include file='yourtemplatename/serverstatus.tpl'} 0 Quote Link to comment Share on other sites More sharing options...
arihantjain Posted September 16, 2008 Share Posted September 16, 2008 thnx a lot......... 0 Quote Link to comment Share on other sites More sharing options...
Lawrence Posted September 17, 2008 Share Posted September 17, 2008 Sorry guys, a slight mis-type. I deleted my template name.the correct code should have been {include file='yourtemplatename/serverstatus.tpl'} No worries. Considering the docs don't make it obvious, it is definitely not something that can be held against you 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted October 18, 2008 Author Share Posted October 18, 2008 Also works well with 3.7.2 0 Quote Link to comment Share on other sites More sharing options...
fishingfool Posted October 19, 2008 Share Posted October 19, 2008 Very nice! Thank you 0 Quote Link to comment Share on other sites More sharing options...
RenatoMN Posted October 19, 2008 Share Posted October 19, 2008 (edited) Thank you Your Template have a error ? "Client Area: Overwrite your /WHMCS/templates/portal/serverstatus.tpl code with this code:" regards The problem with multiple plans can be solved replacing all occurences of: <td rowspan=\"2\"><img src=\"images/statusfailed.gif\"></td> and <td rowspan=\"2\"><img src=\"imagesfailed.gif\"></td> with: <td><img src=\"images/statusfailed.gif\"></td> Edited October 19, 2008 by RenatoMN 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted October 19, 2008 Author Share Posted October 19, 2008 Good catch Renato. Cheers. 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted October 19, 2008 Author Share Posted October 19, 2008 Thanks to Renato for resolving the problem with broken displays where multiple servers are used: Here is the amended code for /WHMCS/templates/portal/serverstatus.tpl {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 $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); {/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} Please refer to the very first post in this thread for the rest of the code and instructions. 0 Quote Link to comment Share on other sites More sharing options...
Drac0 Posted October 20, 2008 Share Posted October 20, 2008 This works very nicely. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Craddock Posted October 24, 2008 Share Posted October 24, 2008 Mines coming up blank, I'm new to this and I think I've got something wrong... http://uploads.screenshot-program.com/my.php?image=upl3423419325.jpg http://www.hostpear.com/status/ 0 Quote Link to comment Share on other sites More sharing options...
redrat Posted October 24, 2008 Author Share Posted October 24, 2008 (edited) Have you put everything in the right folders on your server? Please check that first. The correct file paths for both files needed for this to work are as shown above. And you will need the second file at the beginning of this thread. This is: /WHMCS/templates/portal/serverstatus.tpl Then you need to add the latest code for this new file /public_html/status/index.php which you have to create and then add code for. All that should get this working for you. Post back either way. Edited October 24, 2008 by redrat 0 Quote Link to comment Share on other sites More sharing options...
Craddock Posted October 24, 2008 Share Posted October 24, 2008 I see, /WHMCS/templates/portal/serverstatus.tpl I have the following, /WHMCS/templates/hostpear/serverstatus.tpl How do I fix this, Thanks for your reply. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.