Skip to content

Instantly share code, notes, and snippets.

@underscorephil
Created October 25, 2013 19:13
Show Gist options
  • Save underscorephil/7160229 to your computer and use it in GitHub Desktop.
Save underscorephil/7160229 to your computer and use it in GitHub Desktop.
import SoftLayer.API
apiUsername = ''
apiKey = ''
client = SoftLayer.Client(
username=apiUsername,
api_key=apiKey,
)
servers = [1, 2, 3]
data = {}
for server in servers:
bandwidth_data = client['Hardware_Server'].getObject(id=server, mask='mask[hostname,currentBillableBandwidthUsage]')
data[bandwidth_data['hostname']] = float(bandwidth_data['currentBillableBandwidthUsage'])
for server, value in data.items():
line = '%s: %sGB' % (server, value)
print(line)
print('Total: ' + str(sum(data.values())) + 'GB')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment