Monitoring Packs und Kartenrichtlinien
Mit der API für Monitoring Packs und Kartenrichtlinien können verschiedene Eigenschaften von Monitoring Packs und Kartenrichtlinien abgerufen und festgelegt werden. Darüber hinaus kann es verwendet werden, um eine Liste von Knoten abzurufen, die ein Monitoring Pack oder eine Richtlinie verwenden, und diese Liste durch Hinzufügen und Entfernen von Knoten zu ändern.
Alle unten aufgeführten Anforderungen können auf Monitoring Packs und Kartenrichtlinien angewendet werden
get-monitoring-pack-properties
Die Eigenschaften vom Monitoring Pack abrufen
Rufen Sie die Eigenschaften vom Monitoring Pack basierend auf dem Filter ab
GET/api/rest/2/policies/<policy>?properties=<filter>
Liste der zusätzlichen Eigenschaften des Monitoring Packs
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')
Parameter
| Name | Beschreibung |
|---|---|
| policy | Richtlinien-ID, Name oder Pfad |
| filter | Liste der Eigenschaften. Es werden alle Eigenschaften zurückgegeben. Wenn der Wert nicht angegeben wird, ist der Wert "all" oder "*" |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
{ "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
Die Eigenschaft vom Monitoring Pack abrufen
Rufen Sie eine einzelne Eigenschaft vom Monitoring Pack ab
GET/api/rest/2/policies/<policy>/<property>
Liste der zusätzlichen Eigenschaften des Monitoring Packs
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>')
Parameter
| Name | Beschreibung |
|---|---|
| policy | Richtlinien-ID, Name oder Pfad |
| property | Name der Eigenschaft, die abgerufen werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
{ "id": 78 }
set-monitoring-pack-property
Die Eigenschaft vom Monitoring Pack festlegen
Legen Sie eine Eigenschaft vom Monitoring Pack fest
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)
Parameter
| Name | Beschreibung |
|---|---|
| view | Richtlinien-ID, Name oder Pfad |
| property | Name der zu setzenden Richtlinieneigenschaft |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
{ "status":"ok" }
enable-monitoring-pack
Monitoring Pack aktivieren
Aktivieren Sie die Alarmierung und Datenesammlung vom 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)
Parameter
| Name | Beschreibung |
|---|---|
| view | Richtlinien-ID, Name oder Pfad |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
{ "status":"ok" }
disable-monitoring-pack
Monitoring Pack deaktivieren
Deaktivieren Sie die Alarmierung und Datenesammlung vom 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)
Parameter
| Name | Beschreibung |
|---|---|
| policy | Richtlinien-ID, Name oder Pfad |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
{ "status":"ok" }
get-list-of-nodes-of-the-monitoring-pack
Die Liste der Knoten vom Monitoring Pack abrufen
Rufen Sie alle Knoten ab, die zum Monitoring Pack gehören
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>')
Parameter
| Name | Beschreibung |
|---|---|
| policy | Name, ID oder Pfad zur Richtlinie |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie nicht gefunden |
Ergebnis
[ {"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
Den Knoten zum Monitoring Pack hinzufügen
Fügen Sie dem Monitoring Pack den Knoten hinzu (dies gilt nur für manuelle Monitoring Packs)
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)
Parameter
| Name | Beschreibung |
|---|---|
| view | Name, ID oder Pfad zur Richtlinie |
| node | ID, Name oder IP-Adresse des hinzuzufügenden Knotens |
Statuscodes
| Status Code | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie oder Knoten nicht gefunden |
Ergebnis
{ "status":"ok" }
remove-node-from-the-monitoring-pack
Den Knoten aus dem Monitoring Pack entfernen
Entfernen Sie einen Knoten aus dem Monitoring Pack (dies gilt nur für manuelle Monitoring Packs).
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)
Parameter
| Name | Beschreibung |
|---|---|
| policy | Name, ID oder Pfad zur Richtlinie |
| node | ID, Name oder IP-Adresse des zu entfernenden Knotens |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Richtlinie oder Knoten nicht gefunden |
Ergebnis
{ "status":"ok" }