Server Load Averages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Itworx4me
    Senior Member
    • Jun 2002
    • 151
    • 3.6.x

    Server Load Averages

    Hello,

    I recently installed csf on my server and since then I have lost the Server Load Averages in the admincp. Can someone tell me what port this feature listens to so I can unblock it.

    Thanks,
    Itworx4me
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    It just runs a command or reads a file on the server. Here is the code:

    admincp/index.php

    Code:
    $loadavg = array();
    
    if (PHP_OS == 'Linux' AND function_exists('exec') AND $stats = @exec('uptime 2>&1') AND trim($stats) != '' AND preg_match('#: ([\d.,]+),?\s+([\d.,]+),?\s+([\d.,]+)$#', $stats, $regs))
    {
    	$loadavg[0] = vb_number_format($regs[1], 2);
    	$loadavg[1] = vb_number_format($regs[2], 2);
    	$loadavg[2] = vb_number_format($regs[3], 2);
    }
    else if (PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $stats = @file_get_contents('/proc/loadavg') AND trim($stats) != '')
    {
    	$loadavg = explode(' ', $stats);
    	$loadavg[0] = vb_number_format($loadavg[0], 2);
    	$loadavg[1] = vb_number_format($loadavg[1], 2);
    	$loadavg[2] = vb_number_format($loadavg[2], 2);
    }
    
    if (!empty($loadavg))
    {
    	print_label_row($vbphrase['server_load_averages'], "$loadavg[0]  $loadavg[1]  $loadavg[2] | " . construct_phrase($vbphrase['users_online_x_members_y_guests'], vb_number_format($guests + $members), vb_number_format($members), vb_number_format($guests)), '', 'top', NULL, false);
    }

    Comment

    • Itworx4me
      Senior Member
      • Jun 2002
      • 151
      • 3.6.x

      #3
      Originally posted by Jake Bunce
      It just runs a command or reads a file on the server. Here is the code:

      admincp/index.php

      Code:
      $loadavg = array();
      
      if (PHP_OS == 'Linux' AND function_exists('exec') AND $stats = @exec('uptime 2>&1') AND trim($stats) != '' AND preg_match('#: ([\d.,]+),?\s+([\d.,]+),?\s+([\d.,]+)$#', $stats, $regs))
      {
      	$loadavg[0] = vb_number_format($regs[1], 2);
      	$loadavg[1] = vb_number_format($regs[2], 2);
      	$loadavg[2] = vb_number_format($regs[3], 2);
      }
      else if (PHP_OS == 'Linux' AND @file_exists('/proc/loadavg') AND $stats = @file_get_contents('/proc/loadavg') AND trim($stats) != '')
      {
      	$loadavg = explode(' ', $stats);
      	$loadavg[0] = vb_number_format($loadavg[0], 2);
      	$loadavg[1] = vb_number_format($loadavg[1], 2);
      	$loadavg[2] = vb_number_format($loadavg[2], 2);
      }
      
      if (!empty($loadavg))
      {
      	print_label_row($vbphrase['server_load_averages'], "$loadavg[0]  $loadavg[1]  $loadavg[2] | " . construct_phrase($vbphrase['users_online_x_members_y_guests'], vb_number_format($guests + $members), vb_number_format($members), vb_number_format($guests)), '', 'top', NULL, false);
      }
      Thanks for the reply Jake. Someting is blocking this from happening and it started after I installed csf. So i need to find out what in csf is blocking this from happening. Any ideas?

      Thanks,
      Itworx4me

      Comment

      • Itworx4me
        Senior Member
        • Jun 2002
        • 151
        • 3.6.x

        #4
        Issue has been fixed.

        Thanks,
        Itworx4me

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...