/**
 * Get the current server load for an active cPanel product
 *
 * @param Service $service The product being viewed
 * @return SimpleXMLElement|null
 */
function getLoadAverageFromService(Service $service)
{
    // No need to do anything if the service is not active or suspended on the server.
    if (in_array($service->status, array('Pending', 'Terminated', 'Cancelled', 'Fraud'))) {
        return null;
    }
    // We only want to do this work on cPanel products, use other hooks for other modules.
    if ($service->product->module != 'cpanel') {
        return null;
    }
    // See http://docs.whmcs.com/Interacting_With_The_Database
    $server = Capsule::table('tblservers')->where('id', $service->serverId)->first();
    // See https://github.com/CpanelInc/xmlapi-php
    $cpServer = new xmlapi($server->ipaddress, $server->username, decrypt($server->password));
    // See https://documentation.cpanel.net/display/SDK/WHM+API+0+Functions+-+loadavg
    $loadAverage = $cpServer->loadavg();
    return $loadAverage;
}