Jump to content

Include Server Status in client area


Recommended Posts

Hi again!

 

I'm working on a new template for our site, and I figured that it would be nice for clients to see the server status as soon as they log in (we'll be removing the server status page at some point), but whenever I try to include it into the clientareahome.tpl file, it does show up, but it gives NO info at all, other than "No Servers are currently being monitored", but that only shows up if I doesn't include

 

{if $servers}

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

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

<br />

{literal}
<script>
function getStats(num) {
   jQuery.post('serverstatus.php', 'getstats=1&num='+num, function(data) {
       jQuery("#load"+num).html(data.load);
       jQuery("#uptime"+num).html(data.uptime);
   },'json');
}
function checkPort(num,port) {
   jQuery.post('serverstatus.php', 'ping=1&num='+num+'&port='+port, function(data) {
       jQuery("#port"+port+"_"+num).html(data);
   });
}
</script>
{/literal}

Any idea what I might have to do?

Link to comment
Share on other sites

If I don't include the code above. The serverstatus.tpl is looking like this:

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

<div class="alert alert-block alert-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 alert-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 />

{literal}
<script>
function getStats(num) {
   jQuery.post('serverstatus.php', 'getstats=1&num='+num, function(data) {
       jQuery("#load"+num).html(data.load);
       jQuery("#uptime"+num).html(data.uptime);
   },'json');
}
function checkPort(num,port) {
   jQuery.post('serverstatus.php', 'ping=1&num='+num+'&port='+port, function(data) {
       jQuery("#port"+port+"_"+num).html(data);
   });
}
</script>
{/literal}

<div class="center80">

<table class="table table-striped table-framed">
   <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}
       <tr>
           <td>{$server.name}</td>
           <td class="textcenter" id="port80_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="port21_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="port110_{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter"><a href="{$server.phpinfourl}" target="_blank">{$LANG.serverstatusphpinfo}</a></td>
           <td class="textcenter" id="load{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /></td>
           <td class="textcenter" id="uptime{$num}"><img src="images/loadingsml.gif" alt="{$LANG.loading}" /><script> checkPort({$num},80); checkPort({$num},21); checkPort({$num},110); getStats({$num}); </script></td>
       </tr>
{foreachelse}
       <tr>
           <td colspan="7">{$LANG.serverstatusnoservers}</td>
       </tr>
{/foreach}
   </tbody>
</table>

</div>

{/if}

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

<br />
<p align="right"><img src="images/rssfeed.gif" alt="RSS" align="absmiddle" /> <a href="networkissuesrss.php">{$LANG.announcementsrss}</a></p>
<br />

 

I can't get it to work.

Link to comment
Share on other sites

I tried it. And couldnt get it to work either. it looks like the $servers variable has nothing in it. Like for some reason on that page it doesnt get that information. Not sure how to fix it at this moment.

Edited by synik4l
Link to comment
Share on other sites

This wont work how you expect it to. If you did manage to include the server status pages into another page you would find you have extra headers and footers in the container for it.

 

This is because the file being accessed on the server status page is serverstatus.php which uses a complete template set of header body and footer. basically what you would end up with is a complete page, within a complete page. definitely not the desired affect.

 

If you want to include it in another page you will need to speak to the whmcs team to see if they can put together a modified version of the file that does not take the header or footer.

 

Once you have this, Create a new hook file and use an include on that php file instead, from there you simply assign the contents to a smarty variable to be used on the page you want to create the container.

 

I can see no valid reason for this to be quite honest.

 

You can just make a hook that will do what you need and check if there is a client affecting issue, If there is you can then automatically redirect them to the server status page.

Edited by CDJ Hosting
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