Created
February 9, 2012 15:31
-
-
Save softlayer/1780685 to your computer and use it in GitHub Desktop.
This file contains 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
# Create a network monitor | |
# So we can talk to the SoftLayer API: | |
import SoftLayer.API | |
# For nice debug output: | |
import pprint | |
pp = pprint.PrettyPrinter(indent=4) | |
# Your SoftLayer API username and key. | |
# | |
# Generate an API key at the SoftLayer Customer Portal: | |
# https://manage.softlayer.com/Administrative/apiKeychain | |
apiUsername = 'SET ME' | |
apiKey = 'SET ME' | |
# The ID of the server you wish to mointor | |
serverId = 0 | |
# ID of the query type which can be found with SoftLayer_Network_Monitor_Version1_Query_Host_Stratum/getAllQueryTypes. | |
# This exmaple uses SERVICE PING: Test ping to address, will not fail on slow server response due to high latency or | |
# high server load | |
queryTypeId = 1 | |
# IP address on the previsously defined server to monitor | |
ipAddress = '127.0.0.1' | |
# Create an instance of the SoftLayer_Network_Monitor_Version1_Query_Host service | |
client = SoftLayer.API.Client('SoftLayer_Network_Monitor_Version1_Query_Host', None, apiUsername, apiKey) | |
# Define the SoftLayer_Network_Monitor_Version1_Query_Host templateObject. | |
newMonitor = { | |
'hardwareId': serverId, | |
'queryTypeId': queryTypeId, | |
'ipAddress': ipAddress | |
} | |
# Send the request for object creation and display the return value | |
result = client.createObject(newMonitor) | |
pp.pprint(result) |
I can't get the line:
client = SoftLayer.API.Client('SoftLayer_Network_Monitor_Version1_Query_Host', None, apiUsername, apiKey)
to work I get an error about apiKey being a literal instead of a float. I also tried it wit a url at the end:
client = SoftLayer.API.Client('SoftLayer_Network_Monitor_Version1_Query_Host', None, apiUsername, apiKey, url)
can anyone help?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will
hardwareId
work if you want to create a monitor for a virtual guest? Or do you have to useguestId
instead?