PDF

アトラスビューとフォルダ

ViewsとFolders のAPIを使用すると、NetCrunchでフォルダとビューのデータを追加、削除、アクセス、取得できます。

add-view

ビューを追加

親フォルダが提供されていない場合、アトラスに静的ビューを追加します。ビューは「カスタムビュー」レベルで追加されます

POST/api/rest/2/views

cURL

curl --request POST --url "https://localhost/api/rest/2/views?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New view\"}"

Node.js

const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New View" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views" $viewData = @{ name='New View' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views' data = { "name": "New View" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url, data=data, headers=headers)

パラメータ

Name 説明
name Name of the new view
parent ID, name or path to parent map

ステータスコード

ステータスコード 説明
200 OK
400 Name is missing
400 NetCrunch request error
401 Access Denied
412 No API Key

結果

結果には、追加された(または見つかった)ビューのIDが含まれます。

{ "id": 1001 }

add-folder

フォルダを追加

空のフォルダをアトラスに追加します。親フォルダが提供されていない場合は、「カスタムビュー」レベルで追加されます

POST/api/rest/2/views/folder

cURL

curl --request POST --url "https://localhost/api/rest/2/views/folder?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New Folder\"}"

Node.js

const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views/folder', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New Folder" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/folder" $viewData = @{ name='New Folder' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/folder' data = { "name": "New Folder" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url, data=data, headers=headers)

パラメータ

Name 説明
name Name of the new view
parent ID, name or path to parent map

ステータスコード

ステータスコード 説明
200 OK
400 Name is missing
400 NetCrunch request error
401 Access denied
412 No API key

結果

{ "id": 1001 }

get-view-properties

ビューのプロパティを取得(複数)

フィルターに基づいてビューのプロパティを取得します

List of Properties

List Of Additional IP Network View Properties

GET/api/rest/2/views/<view>?properties=<filter>

cURL

curl --url "http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status"

Python

import requests requests.get('http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status')

パラメータ

Name 説明
view View ID, name or path
filter List of properties. Returns all properties if omitted, value is "all" or "*"

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

{  "id": 1050,  "name": "Parent",  "status": "unknown",  "stats": {    "nodes": {      "total": 0,      "ok": 0,      "unknown": 0,      "warning": 0,      "error": 0,      "alerts": {        "active": 0,        "las24Hours": {          "unacknowledged": 0,          "total": 0,          "critical": 0,          "warning": 0        }      }    },    "maps": {      "total": 2,      "ok": 0,      "unknown": 0,      "warning": 2,      "error": 0    }  },  "path": "/Custom Views",  "isDynamic": true,  "isFolder": true,  "readOnly": false  }

get-view-property

ビュープロパティを取得

ビューの単一のプロパティを取得します

GET/api/rest/2/views/<view>/<property>

List of Properties

[List Of Additional IP Network View Properties](@api-data-properties:ip-network-property-list

cURL

curl --url "http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>')

パラメータ

Name 説明
view Name ID or path to the view
property Name of property to get

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

{ "id": 1001 }

set-view-property

ビュープロパティの設定

ビュープロパティを設定または変更します

PUT/api/rest/2/views/<view>/<property>

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New Name\"}"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New Name" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/1050" $viewData = @{ name='New Name' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050' data = { "name": "New Name" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, data=data, headers=headers)

パラメータ

Name 説明
view View ID, name or path
property Name of view property to set

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View Not Found

結果

{ "status": "ok" }

get-list-of-nodes-in-the-view

ビュー内のノードのリストを取得

ビューに存在するノードのリストを取得します

GET/api/rest/2/views/<view>/nodes

cURL

curl --url "http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>')

パラメータ

Name 説明
view Name ID or path to the view
property Name of property to get

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

[ {"id":1019,"name":"foo","networkAddress":"192.168.1.89","dnsName":"foo.test.com"}, {"id":1019,"name":"bar","networkAddress":"192.168.1.10","dnsName":"bar.test.com"} ]

add-node-to-the-view

ビューにノードを追加

監視対象ノードをビューに追加します

POST/api/rest/2/views/<view>/nodes/<node>

cURL

curl --request POST --url "https://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View') + '/nodes/192.168.1.10' , headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.post(url, headers=headers)

パラメータ

Name 説明
view Name ID or path to the view
node ID, name or IP address of the node to add

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View or node not found

結果

{ "status":"ok" }

remove-node-from-the-view

ビューからノードを削除

ビューからノードを削除します

DELETE/api/rest/2/views/<view>/nodes/<node>

cURL

curl --request DELETE --url "https://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View') + '/nodes/192.168.1.10', headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Delete -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url, headers=headers)

パラメータ

Name 説明
view Name ID or path to the view
node ID, name or IP address of the node to remove

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View or node not found

結果

{ "status":"ok" }

enable-ip-network-view-monitoring

IPネットワークビュー監視を有効化

ビュー内のすべてのノードの監視を有効にします

PUT/api/rest/2/views/<view>/enable

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050/enable?api_key=<your-api-key>"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050/enable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/1050/enable" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050/enable' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, headers=headers)

パラメータ

Name 説明
view View ID, name or path

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

{ "status":"ok" }

disable-ip-network-view-monitoring

IPネットワークビューの監視を無効化

ビュー内のすべてのノードの監視を無効にします

PUT/api/rest/2/views/<view>/disable

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050/disable?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"disabledFrom\": \"2019-01-01T13:27:34.876Z\", \"disabledUntil\": \""2019-02-01T13:27:34.876Z"\"}"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050/disable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "disabledFrom": "2019-01-01T13:27:34.876Z", "disabledUntil": "2019-02-01T13:27:34.876Z" };

PowerShell

$url = "http://localhost/api/rest/2/views/1050/disable" $viewData = @{ disabledFrom: '2019-01-01T13:27:34.876Z', disabledUntil: '2019-02-01T13:27:34.876Z' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050/disable' data = { "disabledFrom": "2019-01-01T13:27:34.876Z", "disabledUntil": "2019-02-01T13:27:34.876Z" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, data=data, headers=headers)

パラメータ

Name 説明
view View ID, name or path
disabledFrom 2018-03-08T13:27:34.876Z
disabledUntil 2018-03-09T13:27:34.876Z

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

{ "status":"ok" }

delete-view

ビューを削除

アトラスからビューを削除します

DELETE/api/rest/2/views/<view>

cURL

curl --request DELETE --url "https://localhost/api/rest/2/views/New%20View?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View'), headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Delete -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url, headers=headers)

パラメータ

Name 説明
view Name or ID or path of the view to delete

ステータスコード

ステータスコード 説明
200 OK
401 Access denied
404 View not found

結果

{ "id": 1001 }