データソースインスタンスの追加

最終更新日: 09 年 2024 月 XNUMX 日

Active Discovery が有効になっていないデータソース インスタンスを追加できます。 API リクエストを行う前に、自分自身を認証する必要があります。

URI: 投稿 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。
isUNCInstanceブーリアンデバイスに対して UNC モニタリングが有効かどうかを示します。
stopMonitoringブーリアンインスタンスの監視が無効になっているかどうかを示します。
displayName文字列(必須の) インスタンスのエイリアスです。これはインスタンスのわかりやすい名前であり、デバイスとデータソースの組み合わせに固有である必要があります。
wildValue2文字列2 次元のアクティブディスカバリにのみ使用されます。使用すると、アクティブな検出の実行中に、トークン ##WILDVALUE## が ALIAS の値に置き換えられ、トークン ##WILDVALUEXNUMX## が XNUMX 番目の部分のエイリアスの値に置き換えられます。この値は、デバイス/データソース/WILDVALUE の組み合わせに固有である必要があります。
groupId整数データソース インスタンスに関連付けられたインスタンス グループ ID。
description文字列データソース インスタンスの説明。
disableAlertingブーリアンインスタンスのアラートが無効になっているかどうかを示します。
systemPropertiesJSON配列 インスタンスに割り当てられるインスタンス レベルのシステム プロパティの名前と値を指定します。
autoPropertiesJSON配列インスタンスに割り当てられるインスタンス レベルの自動プロパティの名前と値を指定します。
customPropertiesJSON配列インスタンスに割り当てられるインスタンス レベルのカスタム プロパティの名前と値を指定します。
lockDescriptionブーリアンActive Discovery が有効かどうか、およびインスタンスの説明が編集可能かどうかを示します。
wildValue文字列(必須の) インスタンスの変数部分。デバイスからデータをクエリするために使用されます。たとえば、SNMP OID ツリーの変数部分です。 2 次元アクティブ検出が使用されない限り、この値はデバイスとデータソースの組み合わせに対して一意である必要があります。

次の Python スクリプトは、api.logicmonitor.com アカウントのデバイス ID 38 の HTTP_Page データソースにインスタンス「google」を追加します。

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
 
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
 
#Request Info
httpVerb ='POST'
resourcePath = '/device/devices/38/devicedatasources/2214/instances'
data = '{"wildValue":"www.google.com","displayName":"google"}'
 
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath
 
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
 
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
 
print requestVars
 
#Construct signature
digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
 
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':'3'}
 
#Make request
response = requests.post(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Pythonの3

構成コレクションをデバイスに追加する

LogicMonitor REST API v3 を使用して、構成コレクションをデバイスに追加できます。

URI: 投稿 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config/configCollection

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。
instanceId整数(必須の) 構成コレクションを追加するインスタンス ID。
記事上で