Created
September 27, 2011 13:45
-
-
Save enygma/1245075 to your computer and use it in GitHub Desktop.
Getting the raw graph data for a SoftLayer server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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