監視パックとマップポリシー
監視パックおよびマップポリシーAPIを使用すると、監視パックおよびマップポリシーのさまざまなプロパティを取得および設定できます。また、監視パックまたはポリシーを使用しているノードのリストを取得し、ノードを追加および削除してそのようなリストを変更することもできます。
以下の 監視パック と マップポリシーのリクエストに適用できます。
get-monitoring-pack-properties
監視パックのプロパティを取得する(複数)
フィルターに基づいて監視パックのプロパティを取得します
GET/api/rest/2/policies/<policy>?properties=<filter>
List Of Additional Monitoring Pack Properties
cURL
curl --url "http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU?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/policies/CPU?api_key=<your-api-key>&properties=name,status"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU?api_key=<your-api-key>&properties=name,status')
パラメータ
| Name | 説明 |
|---|---|
| policy | Policy ID, name or path |
| filter | List of properties. Returns all properties if omitted, value is "all" or "*" |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
結果
{ "id": 1050, "name": "CPU", "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": "/Monitoring Packs/Operating Systems/Windows/CPU", "isDynamic": true, "isFolder": true, "readOnly": false }
get-monitoring-pack-property
監視パックのプロパティを取得する
監視パックの単一のプロパティを取得します
GET/api/rest/2/policies/<policy>/<property>
List Of Additional Monitoring Pack Properties
cURL
curl --url "http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU/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/policies/CPU/id?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU/id?api_key=<your-api-key>')
パラメータ
| Name | 説明 |
|---|---|
| policy | Policy ID, name or path |
| property | Name of property to get |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
結果
{ "id": 78 }
set-monitoring-pack-property
監視パックのプロパティを設定する
監視パックのプロパティを設定する
PUT/api/rest/2/policies/<policy>/<property>
cURL
curl --request PUT --url "https://localhost/api/rest/2/policies/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/policies/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/policies/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/policies/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 | Policy ID, name or path |
| property | Name of policy property to set |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
結果
{ "status":"ok" }
enable-monitoring-pack
監視パックを有効にする
監視パックのすべてのアラートとデータ収集を有効にします
PUT/api/rest/2/policies/<view>/enable
cURL
curl --request PUT --url "https://localhost/api/rest/2/policies/1050/enable?api_key=<your-api-key>"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/policies/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/policies/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/policies/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 | Policy not found |
結果
{ "status":"ok" }
disable-monitoring-pack
監視パックを無効にする
監視パックのすべてのアラートとデータ収集を無効にします
PUT/api/rest/2/policies/<policy>/disable
cURL
curl --request PUT --url "https://localhost/api/rest/2/views/1050/disable?api_key=<your-api-key>"
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>' } }; 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/disable" $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/disable' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, headers=headers)
パラメータ
| Name | 説明 |
|---|---|
| policy | Policy ID, name or path |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy not found |
結果
{ "status":"ok" }
get-list-of-nodes-of-the-monitoring-pack
監視パックのノードのリストを取得する
監視パックに属するすべてのノードを取得します
GET/api/rest/2/policies/<policy>/nodes
cURL
curl --url "http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/policies/CPU/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/policies/CPU/nodes?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/policies/CPU/nodes?api_key=<your-api-key>')
パラメータ
| Name | 説明 |
|---|---|
| policy | Name ID or path to the policy |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy 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-monitoring-pack
監視パックへのノードの追加
監視パックにノードを追加します(手動監視パックにのみ適用)
POST/api/rest/2/policies/<view>/nodes/<node>
cURL
curl --request POST --url "https://localhost/api/rest/2/policies/CPU/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/policies/CPU/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/policies/CPU/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/policies/CPU/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 policy |
| node | ID, name or IP address of the node to add |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy or node not found |
結果
{ "status":"ok" }
remove-node-from-the-monitoring-pack
監視パックからノードを削除する
監視パックからノードを削除する(手動監視パックにのみ適用)
DELETE/api/rest/2/policies/<policy>/nodes/<node>
cURL
curl --request DELETE --url "https://localhost/api/rest/2/policies/CPU/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/policies/CPU/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/policies/CPU/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/policies/CPU/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url, headers=headers)
パラメータ
| Name | 説明 |
|---|---|
| policy | Name ID or path to the policy |
| node | ID, name or IP address of the node to remove |
ステータスコード
| ステータスコード | 説明 |
|---|---|
| 200 | OK |
| 401 | Access denied |
| 404 | Policy or node not found |
結果
{ "status":"ok" }