Jump to content

Seperate Server Status


Recommended Posts

Hello All,

 

I was just wondering if it is possible to separate the server status at all so we could show custom ports per server group or some type of filtering maybe.

 

E.g.

 

Shared Hosting

 

Server (HTTP) (FTP) (POP3) (CPANEL) (Server Load) (Uptime)

 

Reseller Hosting

 

Server (HTTP) (FTP) (POP3) (CPANEL) (WHM) (Server Load) (Uptime)

 

Custom Servers

 

Server (HTTP) (Server Load) (Uptime)

 

Im not too sure if it is possible but I just thought id check - ive tried searching the forums but I couldn't find too much about it

Link to comment
Share on other sites

Looks like a good idea. Can you post the solution here for the rest of us?

 

 

you need to add servers to server groups,

 

Then you use the server group to seperate the monitoring, all very mundane stuff, but besides that, it looks to me like ol chap has 3 servers.

 

2 shared

 

1 reseller (this one is also a shared one if you look at uptime)

 

1 backup

 

...

 

 

First off, i would look at showing by client group, EG clients on the server, not a whole network page. secondly, they would also be logged in.

 

if they are not logged in, they see a login page. best way i think. then again, if you have thousands of servers, might as well show the world how big you are.

Link to comment
Share on other sites

@disgruntled - Thanks for the feedback I see what you mean about the login page, the idea behind the current setup was because each customer would be able to look at their own section e.g. shared / reseller and us to be able to open the page up a bit rather than all servers being in a single row stuck together and also its open to the public so everyone will be able to see how our servers are currently coping and our up-time without being a current customer.

 

We thought it would be a good idea to spread the systems out a little bit into different sections regardless of servers so shared customers didn't have to see the WHM port etc etc.

Link to comment
Share on other sites

@disgruntled - Thanks for the feedback I see what you mean about the login page, the idea behind the current setup was because each customer would be able to look at their own section e.g. shared / reseller and us to be able to open the page up a bit rather than all servers being in a single row stuck together and also its open to the public so everyone will be able to see how our servers are currently coping and our up-time without being a current customer.

 

We thought it would be a good idea to spread the systems out a little bit into different sections regardless of servers so shared customers didn't have to see the WHM port etc etc.

 

Hi plazmahost,

Yes, one would be curious on the specifics of the code you used. I know one method was to pull the server ID from the database to separate then but not 100% sure on that.

 

Mind sharing?

Link to comment
Share on other sites

would you happen to have the code to do this?

 

I dont want any cash or anything, but yes, i have the code for you right here, This way uses some php in the template, massive hack i know. but hopefully whmcs will eliminate these issues soon by releasing this as a setting instead of a hack :P

 

 

This is the "default" tpl file but should work for all system, Now you can also follow my join example and bring in client checks to see who is in the server and then highlight servers for clients related services.

 

Debug is commented out its just below that if you compare the two files you will spot my hack

{include file="$template/pageheader.tpl" title=$LANG.networkstatustitle desc=$LANG.networkstatusintro}

<div class="alert-message block-message warning">
<p class="textcenter fontsize3">
<a href="{$smarty.server.PHP_SELF}?view=open" class="networkissuesopen">{$opencount} {$LANG.networkissuesstatusopen}</a>     
<a href="{$smarty.server.PHP_SELF}?view=scheduled" class="networkissuesscheduled">{$scheduledcount} {$LANG.networkissuesstatusscheduled}</a>     
<a href="{$smarty.server.PHP_SELF}?view=resolved" class="networkissuesclosed">{$resolvedcount} {$LANG.networkissuesstatusresolved}</a>
</p>
</div>

{foreach from=$issues item=issue}

{if $issue.clientaffected}<div class="alert-message block-message warning">{/if}

   <h3>{$issue.title} ({$issue.status})</h3>
   <p><strong>{$LANG.networkissuesaffecting} {$issue.type}</strong> - {if $issue.type eq $LANG.networkissuestypeserver}{$issue.server}{else}{$issue.affecting}{/if} | <strong>{$LANG.networkissuespriority}</strong> - {$issue.priority}</span></p>
   <br />
   <blockquote>
   {$issue.description}
   </blockquote>
   <p><strong>{$LANG.networkissuesdate}</strong> - {$issue.startdate}{if $issue.enddate} - {$issue.enddate}{/if}</p>
   <p><strong>{$LANG.networkissueslastupdated}</strong> - {$issue.lastupdate}</p>

{if $issue.clientaffected}</div>{/if}

{foreachelse}

<p class="textcenter"><strong>{$noissuesmsg}</strong></p>

{/foreach}

<div class="pagination">
   <ul>
       <li class="prev{if !$prevpage} disabled{/if}"><a href="{if $prevpage}{$smarty.server.PHP_SELF}?{if $view}view={$view}&{/if}page={$prevpage}{else}javascript:return false;{/if}">← {$LANG.previouspage}</a></li>
       <li class="next{if !$nextpage} disabled{/if}"><a href="{if $nextpage}{$smarty.server.PHP_SELF}?{if $view}view={$view}&{/if}page={$nextpage}{else}javascript:return false;{/if}">{$LANG.nextpage} →</a></li>
   </ul>
</div>

{if $servers}

{include file="$template/subheader.tpl" title=$LANG.serverstatustitle}

<p>{$LANG.serverstatusheadingtext}</p>

<br />
{*debug*}
<div class="center80">
{php}
$sql = "SELECT DISTINCT tblservergroups.name as groupname, tblservergroupsrel.serverid, tblservers.name FROM tblservers, tblservergroups, tblservergroupsrel WHERE tblservergroups.id = tblservergroupsrel.groupid AND tblservers.id = tblservergroupsrel.serverid ";
$result = mysql_query($sql) or die(mysql_error());
$servergroups = array();
while ($row = mysql_fetch_assoc($result)){
	$servergroups[] = $row;
}
$this->assign('groups', $servergroups);
{/php}
{foreach from=$groups item=group}
<h3>{$group.groupname}</h3>
<table class="zebra-striped">
	<thead>
		<tr>
			<th>{$LANG.servername}</th>
			<th class="textcenter">HTTP</th>
			<th class="textcenter">FTP</th>
			<th class="textcenter">POP3</th>
			<th class="textcenter">{$LANG.serverstatusphpinfo}</th>
			<th class="textcenter">{$LANG.serverstatusserverload}</th>
			<th class="textcenter">{$LANG.serverstatusuptime}</th>
		</tr>
	</thead>
	<tbody>

			{foreach from=$servers key=num item=server}
				{if $server.name eq $group.name}
				<tr>
					<td>{$server.name}</td>
					<td class="textcenter">{get_port_status num="$num" port="80"}</td>
					<td class="textcenter">{get_port_status num="$num" port="21"}</td>
					<td class="textcenter">{get_port_status num="$num" port="110"}</td>
					<td class="textcenter"><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
					<td class="textcenter">{$server.serverload}</td>
					<td class="textcenter">{$server.uptime|replace:'Days':$LANG.days}</td>
				</tr>
				{/if}
			{foreachelse}
			<tr>
				<td colspan="7">{$LANG.serverstatusnoservers}</td>
			</tr>
			{/foreach}
	</tbody>
</table>
{/foreach}
</div>

{/if}

{if $loggedin}<p>{$LANG.networkissuesaffectingyourservers}</p>{/if}

<br />
<br />

 

You will also find there are many other services you can monitor, great if you dedicate servers to specific tasks, locking down all none essential ports and leaving open just the bare two or 3 that may be required.

 

Enjoy

Edited by disgruntled
cough debug comment out cough cough
Link to comment
Share on other sites

Does anyone know how "only" show the server the client is on? For example:

 

Host provider has servers A, B, C, D. They have a customer on server D and doesn't care about the status of server A, B, C. They only want to see their server status. Please note the the WHMCS install is on a different server.

 

I think this would be helpful for clients that have dedicated boxes with your company or several Virt Servers in a clustered or non-clustered array.

 

I am not sure what variables would need to be tweaked on that server status page.

Link to comment
Share on other sites

Im a little busy today but if i have a spare hour later on il do the client server only option to add onto it, its only another look up, (wont be ajax though i will work it off the same template)

 

 

Ok so i got my hour, and boy did i need it lol.

change the template php in the above to the below. This doesnt need a modification to anything else in the above code.

 

{*debug*}
{php}
$sql = "SELECT DISTINCT 
		b.name as servername, 
			d.name as groupname
FROM 
	tblhosting a,
		tblservers b, 
			tblservergroupsrel c,
				tblservergroups d
WHERE a.userid = '" . $this->_tpl_vars['clientsdetails']['userid'] . "'
	AND a.server = b.id
		AND b.id = c.serverid 
			AND c.groupid = d.id";

$result = mysql_query($sql) or die(mysql_error());
$servergroups = array();
while ($row = mysql_fetch_assoc($result)){
	$servergroups[] = $row;
}
$this->assign('groups', $servergroups);
{/php}

 

Due to the change in how this works

 

Open lang/english.php and go to line: 1256

$_LANG['serverstatusheadingtext'] = "Below is a real-time overview of our servers where you can check if there's any known issues.";

 

To This

$_LANG['serverstatusheadingtext'] = "Below is a real-time overview of servers where you have have an account hosted";

[/php]

 

Enjoy, and test thoroughly before use.

 

 

The first step as always should be to back up the files (no need for database were only using selects here so nothing is being changed) .

 

Note: i am going to expand this as now i have the bit in my teeth, i will add in the option to see which accounts are listed on the servers shown so at a glance your clients can see which of their websites are affected if any.

 

I would be grateful for somebody to port this to ajax, its not my strongpoint and would take me far too long.

Edited by disgruntled
i like editing
Link to comment
Share on other sites

Looks like disgruntled hit the nail on the head with the code - That's roughly the one we use for ours , Ours uses the Ajax version but all in all spot on :)

Would you be willing to share your template data for the AJAX version and custom ports?

Thanks

Link to comment
Share on other sites

just dropped this in, and it's doing some strange, doesn't seem to be grouping them - any ideas?

[ATTACH=CONFIG]2863[/ATTACH]

 

You are correct, let me look into it, i was just about to post up one with domains added too, but now i see when several servers are added to a group its splitting them into seperate groups, not the desired effect.

 

Works wonderfully with just the single server in a group. I will fix this.

Link to comment
Share on other sites

That would be awesome if you could share the AJAX portion for the server status.

 

 

Im working on this.

 

 

I have it now set to two groups, but the problem i have now is that all the group display exactly the same groups, i just cant seem to clear them out, the one query i am running seems like it might be a tad heavy so i dread running a second but i will try to find the way forward.

 

The problem i have is that every time WHMCS script portion runs its just does its own thing no matter what and i cant find a way to stop it from displaying servers that are not in the group.... at the moment its displaying all as i said. i must have my query wrong.

Link to comment
Share on other sites

[ATTACH=CONFIG]2866[/ATTACH]

 

The screen shot above is an example of what my edits to the status page will do (this took me all day to figure out the thing so many joins on one query has me tied in knots with more knots tied to them, so i decided it was better to split the queries up.

 

if somebody wants to run some benchmarks on this i would be happy to see what comes up because i was having major loading issue with my original sql query, i suspect that was very likely because i was joining 4 sections of table together and coming up with way too many results. but anyway, the below code work, i dont know how it compares as i cant benchmark, but i think with some ajax into this it will be even better as the page can display then wait for the servers to respond.

 

Anyway, enough of my babble, heres what you have all been waiting for :) Oh one last thing, you see it is in split "server Groups" Only the groups that a client has a hosting account in show up on the status page. (so who has the AJAX.. ive spilled my coffee)

 

File: whmcs/templates/default/serverstatus.tpl

 

I have included the containing div tags so you can easily see where to put it.

<div class="center80">
{php}
$groups_arr = array();
$sql_groups = "SELECT DISTINCT groups.name, groups.id, relate.groupid, relate.serverid 
				FROM tblservergroups groups, tblservergroupsrel relate, tblhosting hosting
				WHERE 
					hosting.userid =  '" . $this->_tpl_vars['clientsdetails']['userid'] . "'
					AND relate.serverid = hosting.server
					AND	groups.id = relate.groupid
					GROUP BY groups.name
					ORDER BY groups.name ASC";
$res_group = mysql_query($sql_groups) or die(mysql_error());
while ($row = mysql_fetch_assoc($res_group)) {
	$groups_arr[] = $row;
}
$this->assign('groups', $groups_arr);

$servers_arr = array();
$sql_servers = "SELECT DISTINCT servers.name, servers.id, relate.groupid
				FROM tblservers servers, tblservergroupsrel relate, tblhosting hosting
				WHERE 
					hosting.userid =  '" . $this->_tpl_vars['clientsdetails']['userid'] . "'
					AND relate.serverid = hosting.server
					AND	servers.id = relate.serverid
					ORDER BY servers.name ASC";
$res_servers = mysql_query($sql_servers) or die(mysql_error());
while ($row = mysql_fetch_assoc($res_servers)) {
	$servers_arr[] = $row;
}
$this->assign('serving', $servers_arr);

$domains_arr = array();
$sql_domain = "SELECT domain, server FROM tblhosting WHERE userid = '" . $this->_tpl_vars['clientsdetails']['userid'] . "'";
$res_domain = mysql_query($sql_domain) or die(mysql_error());
while ($row = mysql_fetch_assoc($res_domain)){
	$domain_arr[] = $row;
}
$this->assign('domains', $domain_arr);
{/php}
{foreach from=$groups item=grouped}
<h3>{$grouped.name}</h3>
<table class="zebra-striped">
		<thead>
			<tr>
				<th>{$LANG.servername}</th>
				<th class="textcenter">HTTP</th>
				<th class="textcenter">FTP</th>
				<th class="textcenter">POP3</th>
				<th class="textcenter">{$LANG.serverstatusserverload}</th>
				<th class="textcenter">{$LANG.serverstatusuptime}</th>
			</tr>
		</thead>
		<tbody>

		{foreach from=$servers key=num item=server}
				{foreach item=served from=$serving}
					{if $served.name eq $server.name and $served.groupid eq $grouped.id}
					<tr>
						<td>{$server.name}</td>
						<td class="textcenter">{get_port_status num="$num" port="80"}</td>
						<td class="textcenter">{get_port_status num="$num" port="21"}</td>
						<td class="textcenter">{get_port_status num="$num" port="110"}</td>
						<td class="textcenter">{$server.serverload}</td>
						<td class="textcenter">{$server.uptime|replace:'Days':$LANG.days}</td>
					</tr>
					<tr>
						<th colspan="1">Websites</th>
						<td colspan="5">
							{foreach item=domain from=$domains}
								{if $domain.server eq $served.id}
									{$domain.domain} 
								{/if}
							{/foreach}
						</td>
					</tr>
					{/if}
				{/foreach}
		{/foreach}
		</tbody>
	</table>
{/foreach}
</div>

 

File: whmcs/lang/english.php Line 1256

 

From This

$_LANG['serverstatusheadingtext'] = "Below is a real-time overview of our servers where you can check if there's any known issues.";

 

To this

$_LANG['serverstatusheadingtext'] = "Below is a real-time overview of servers where you have an account hosted"; 

Edited by disgruntled
No reason just thought i would keep up the trend.. haha
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