Monitoring 通过API向虚拟来宾添加基本监控包

Monitoring 通过API向虚拟来宾添加基本监控包,monitoring,ibm-cloud-infrastructure,Monitoring,Ibm Cloud Infrastructure,是否可以通过Softlayer API添加监控包。在门户上,我可以进入监控部分并订购一个监控包-Basic,它将把它与虚拟客户机关联起来 是否可以在placeOrder调用期间或在初始placeOrder调用之后执行此操作,即如果客户希望在配置服务器后添加基本监控 我试图研究一些例子,但它们都假设有一个监控代理可用,但在我的案例中没有。我还研究了如何从产品包服务中提取基本监控包,但不确定 我正在使用Python来实现这一点,因此在创建期间或创建之后关联监控服务的任何指针都将非常有用 提前谢谢 试

是否可以通过Softlayer API添加监控包。在门户上,我可以进入监控部分并订购一个监控包-Basic,它将把它与虚拟客户机关联起来

是否可以在placeOrder调用期间或在初始placeOrder调用之后执行此操作,即如果客户希望在配置服务器后添加基本监控

我试图研究一些例子,但它们都假设有一个监控代理可用,但在我的案例中没有。我还研究了如何从产品包服务中提取基本监控包,但不确定

我正在使用Python来实现这一点,因此在创建期间或创建之后关联监控服务的任何指针都将非常有用

提前谢谢

试试这个:

"""
Order a Monitoring Package

Build a SoftLayer_Container_Product_Order_Monitoring_Package object for a new
monitoring order and pass it to the SoftLayer_Product_Order API service to order it
In this care we'll order a Basic (Hardware and OS) package with Basic Monitoring Package - Linux
configuration for more details see below

Important manual pages:
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Monitoring_Package
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Monitoring_Agent_Configuration_Template_Group

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer

USERNAME = 'set me'
API_KEY = 'set me'

"""
Build a skeleton SoftLayer_Container_Product_Order_Monitoring_Package object
containing the order you wish to place.
"""
oderTemplate = {
    'complexType': 'SoftLayer_Container_Product_Order_Monitoring_Package',
    'packageId': 0,  # the packageID for order monitoring packages is 0
    'prices': [
        {'id': 2302}  # this is the price for Monitoring Package - Basic ((Hardware and OS))
    ],
    'quantity': 0,  # the quantity for order a service (in this case monitoring package) must be 0
    'sendQuoteEmailFlag': True,
    'useHourlyPricing': True,
    'virtualGuests': [
        {'id': 4906034}  # the virtual guest ID where you want add the monitoring package
    ],
    'configurationTemplateGroups': [
        {'id': 3}  # the templateID for the monitoring group (in this case Basic Monitoring package for Unix/Linux operating system.)
    ]
}

# Declare the API client to use the SoftLayer_Product_Order API service
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
productOrderService = client['SoftLayer_Product_Order']

"""
verifyOrder() will check your order for errors. Replace this with a call to
placeOrder() when you're ready to order. Both calls return a receipt object
that you can use for your records.

Once your order is placed it'll go through SoftLayer's provisioning process.
"""
try:
    order = productOrderService.verifyOrder(oderTemplate)
    print(order)
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to verify the order! faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)
这是一个创建网络监控的示例

"""
Create network monitoring

The script creates a monitoring network with Service ping
in a determinate IP address

Important manual pages
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Monitor_Version1_Query_Host
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Monitor_Version1_Query_Host

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer.API
from pprint import pprint as pp

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'


# The ID of the server you wish to monitor
serverId = 7698842

"""
ID of the query type which can be found with SoftLayer_Network_Monitor_Version1_Query_Host_Stratum/getAllQueryTypes.
This example 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 previously defined server to monitor
ipAddress = '10.104.50.118'

# Declare the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
networkMonitorVersion = client['SoftLayer_Network_Monitor_Version1_Query_Host']

# Define the SoftLayer_Network_Monitor_Version1_Query_Host templateObject.
newMonitor = {
    'guestId': serverId,
    'queryTypeId': queryTypeId,
    'ipAddress': ipAddress
}

# Send the request for object creation and display the return value
try:
    result = networkMonitorVersion.createObject(newMonitor)
    pp(result)
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to create new network monitoring "
          % (e.faultCode, e.faultString))
    exit(1)

问候

非常感谢。如果我添加了另一个示例来创建一个带有服务ping的网络监控,我将尝试这个示例,也许这个示例对您也有帮助