Skip to content

Instantly share code, notes, and snippets.

@enygma
Created September 27, 2011 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enygma/1245075 to your computer and use it in GitHub Desktop.
Save enygma/1245075 to your computer and use it in GitHub Desktop.
Getting the raw graph data for a SoftLayer server
<?php
/**
* Pull the bandwidth data from the API by server's tracking object ID
*
*/
$soapClient = SoftLayer_Controller_Action_Helper_SoapClient::getSoapClient('SoftLayer_Hardware_Server', $deviceId);
$objectMask = new SoftLayer_Soap_ObjectMask();
$objectMask->metricTrackingObject;
$soapClient->setObjectMask($objectMask);
/** Pull the device's metric tracking object ID */
$device = $soapClient->getObject();
$trackingObjectId = $device->metricTrackingObject->id;
// use the tracking ID and a custom object to get the graph data
$soapClient = SoftLayer_Controller_Action_Helper_SoapClient::getSoapClient('SoftLayer_Metric_Tracking_Object', $trackingId);
/** Set up some config settings */
$pollFrequency = 3600;
$type = 'public';
$startDateDt = new DateTime('2011-09-01');
$endDateDt = new DateTime('2011-09-27');
$bandwidthData = $soapClient->getBandwidthData($startDateDT->format('U'),$endDateDT->format('U'),$type,$pollFrequency);
var_dump($bandwidthData);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment