2016-09-28 7 views
1

ここではSevOneについて多くの人々が話しているわけではありませんが、その価値はあります。 Im SevOne NMS 5.6を使用して、デバイス用に収集されたデータをAPI(RestまたはSoap)経由でエクスポートする方法を探しています。これまでのところ、私はこれに関して有用な何かを見つけられませんでした(データマイナーがありますが、APIアプローチが私たちより好まれています)。 これが可能かどうかは誰も知っていますか?もしそうなら、どうですか?SevOne APIを使用して指標を取得する

ありがとうございます!そこに誰のため

答えて

1

は、インジケータ下RESTのAPIのドキュメントで掘り、私はこのendpontが見つかりました:

/API/V1 /デバイス/ {DEVICEID} /オブジェクト/ {OBJECTID} /インジケータ/

import requests 
import json 
import time 

# Log into SevOne API. 
address = 'http://sevone.com/api/v1/' 
creds = {'name': 'user', 'password':'pass'} 
r = requests.post(address + "authentication/signin", 
        data=json.dumps(creds), 
        headers = { 'content-type': 'application/json' }) 
response = json.loads(r.text) 

# Open a session for credential handling. 
session = requests.Session() 
session.headers.update({ 'content-type': 'application/json', 
         'X-AUTH-TOKEN': response[ 'token' ]}) 

# Time interval in linux epoch (up to miliseconds). 
endTime = int(time.time() * 1000) 
startTime = endTime - 1800000 

# Let's get the devices, objects and indicators to collect metrics from them. By default, you'll get the first twenty devices. 
r = session.get(address + 'devices') 
devices = json.loads(r.text) 

for device in devices['content']: 
    print "Device: {} id: {}".format(device[ 'name' ], device[ 'id' ]) 
    r = session.get(address 
      + 'devices/{}?includeIndicators=true'.format(device[ 'id' ])) 
    response = json.loads(r.text) 

    for object in response[ 'objects' ]: 
    print "* Object: {} id: {}".format(object[ 'name' ], object[ 'id' ]) 

    for indicator in object['indicators']: 
     print "** indictorId: {}".format(
     indicator[ 'id' ]) 
     indicatorDataUrl = address + "devices/{}/objects/{}/indicators/{}/data".format( 
     indicator['deviceId'], indicator['objectId'], indicator['id']) 

     params = { 'startTime': startTime, 'endTime': endTime } 
     r = session.get(indicatorDataUrl, params=params) 

     print r.url 
     print r.text 

あなた'LL GE:{indicatorId} /データ

は、だからと、あなたは、このような任意の/すべてのデバイス、(いくつかのPythonは以下の)から情報を取得するための便利なソリューションを作成することができますこのような応答のようなもの:

<list> 
    <dataPoint> 
    <value>30.0</value> 
    <time>1476300851000</time> 
    <focus>1</focus> 
    </dataPoint> 
    <dataPoint> 
    <value>30.0</value> 
    <time>1476301151000</time> 
    <focus>1</focus> 
    </dataPoint> 
    <dataPoint> 
    <value>30.0</value> 
    <time>1476301451000</time> 
    <focus>1</focus> 
    </dataPoint> 
    <dataPoint> 
    <value>30.0</value> 
    <time>1476301751000</time> 
    <focus>1</focus> 
    </datapoint> 
</list> 

希望します。

関連する問題