Created
October 25, 2013 19:13
-
-
Save underscorephil/7160229 to your computer and use it in GitHub Desktop.
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
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