Jump to content

How to add extra server status protocols


YodaCows

Recommended Posts

First off, I in NO WAY guarantee this code will work for you. It is merely a working example for you to copy and/or modify. After a long, unproductive search I came across this code and made it work. I can help with the basics, but don't ask me what everything does because I'm not a PHP guru (also I didn't write the code).

 

This code will only show the green or red ball, it makes no use of the yellow status.

 

I have not thoroughly tested it on a Linux server because I do not have root access to start and stop the services. The extent of my Linux testing was checking various ports that I know are/aren't being utilized...the status seems to work. However on my local Windows XP I tested out the MySQL, FTP, and SSH ports and they all showed the correct status, so I assume it is working on my Linux server too. If anyone with a Linux dedicated server is willing to test this out and post the results I'd appreciate it. I'd test it all out on my Linux desktop but I've exhausted my energy on this for tonight.

 

I know a lot of people have asked about adding the extra status protocols to various areas of WHMCS. Please, feel free to improve the code and use it how you like. There may be (and probably are) better ways to implement this, but it works and that's all I'm concerned with at 2:30am.

 

Ok, now time for the good stuff:

If you want the Server Status page to check extra protocols (ports) like MySQL, SSH, cPanel, etc. here's what to do:

(Don't worry, 90% of the work involves copy & paste)

 

1) Open /templates/default/serverstatus.tpl

2) Add in an extra column near the top (just copy one of them, such as the POP3 column and paste it below, changing the text to MySQL)

Example:

<td width="11%" id="serverstatusheading">POP3</td>


<td width="11%" id="serverstatusheading">POP3</td>
<td width="11%" id="serverstatusheading">MySQL</td>

3) Further down the page you'll see your POP3 cell with code in it, copy and paste it below.

Example

<td width="11%" id="serverstatusrow">{$server.statuspop3}</td>


<td width="11%" id="serverstatusrow">{$server.statuspop3}</td>
<td width="11%" id="serverstatusrow">{$server.statuspop3}</td>

Here's where the fun comes in

4) Replace the {$server.statuspop3} code in the cell you just pasted with this:

{php}
error_reporting(0);
$IP = array(
"Login Server" => "my.ip:3306",
); while(list($ServerName,$Host)=each($IP)) {
list($IPAddress,$Port)=explode(":",$Host);
if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
echo("<img src=\"./../images/status/ball_green.gif\" width=\"15px\" height=\"15px\"/>");
fclose($fp);
}
else {
echo("<img src=\"./../images/status/ball_red.gif\" width=\"15px\" height=\"15px\"/>");
}
echo ("");
}
{/php}

5) Replace my.ip with your IP, and the port you want to check. For this MySQL example, leave it at 3306. My status ball images are in the default location, if you haven't moved yours you shouldn't need to change the image source.

6) Check it out and see if it works (you'll need MySQL running on your server on [default] port 3306).

7) That's it. Repeat the above steps, making sure to change the port number to the corresponding protocol. You might want to change the comment at the top so you know which code is for what service. If you're adding 3 or 4 new protocols you might want to adjust your <td width> values, otherwise your uptime will be squished and displayed on 2 lines.

 

Unsure of which protocols are running on which ports?

Here's a few sites with common service ports:

http://www.webopedia.com/quick_ref/portnumbers.asp

http://www.iss.net/security_center/advice/Exploits/Ports/

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/cnet/cnfc_por_SIMW.mspx

http://www.iana.org/assignments/port-numbers

Still looking for a port number? Search for it.

 

Note that these are only the default ports, if you are a reseller your host may not be running the services on the ports listed. If it is not working, contact your host to see what ports they are running the service on. Also, I've read that some hosts may not let you use fsockopen to connect to ports other than 80; but I believe that's mainly for shared hosts....but then I suppose they wouldn't have use for WHMCS anyway. Just keep these in mind in case you're having trouble getting it to work.

 

If you're really stuck, PM me and I can send you the contents of my serverstatus.tpl, but I think everyone can handle a little copy & paste.

 

I hope this is as helpful to others as it is to me.

 

~YC

Link to comment
Share on other sites

  • 10 years later...

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