Service-level response times are the same as for general-release features. Although this new feature/technology has undergone significant testing and is not expected to change significantly prior to general release, the use of this feature/technology is not recommended for production environments. You are encouraged to use this feature/technology for development and testing purposes only.
To send custom metering data to the RightScale system so that you can generate reports (by customer) for billing purposes. Custom metrics will be displayed as additional columns in the metering reports. Each ISV account can add up to two (2) custom metrics.
<?php /**** SEND CUSTOM USAGE DATA TO RIGHTSCALE ****/ $custom_metric1 = 0; // Your custom metrics are calculated elsewhere $custom_metric2 = 0; // They must be integers /** Construct API URL using RightScale environment **/ $api_url = `source /var/spool/ec2/user-data.sh; env | grep RS_API_URL`; $uri = split("=",$api_url); $uri = trim($uri[1]) . "/set_custom_lodgement"; // The API call to send custom data /** Set Period and Usage Data **/ // Set the time to current month or day in format YYYY_MM or YYYY_MM_DD // Note that any previous value for that time will be overwritten // Day values are automatically aggregated into month values by RightScale $time = date('Y_m_d'); // return current date in format YYYY_MM_DD (Ex: '2010_08_27') //$time = date('Y_m'); // return current date in format YYYY_MM (Ex: '2010_08') // Set both the label for the custom metric and the actual usage $quantity = '{"MB/s":'.$custom_metric1.',"DB Size":'.$custom_metric2.'}'; $ch = curl_init($uri); $encoded = ''; $encoded .= urlencode('api_version').'='.urlencode('1.0').'&'; $encoded .= urlencode('time').'='.urlencode($time).'&'; $encoded .= urlencode('quantity').'='.urlencode($quantity); curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_exec($ch); curl_close($ch); ?>
curl -H 'X-API-VERSION:1.0' -d api_version='1.0' -d time='2010_11_18' -d quantity='{"custom_metric":1}' -X PUT https://my.rightscale.com/api/inst/ec2_instances/$APITOKEN/set_custom_lodgement
On Linux instances, this bash command will create an hourly cron job to execute the lodgements script at /root/rs_lodgements.php
echo "* */1 * * * root php -e /root/rs_lodgements.php >> /var/log/rs_lodgements.log 2>&1" > /etc/cron.d/rs_lodgements
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.