Knoten
Die API der Knoten bietet viele Möglichkeiten zum Zugriff, Ändern, Hinzufügen und Entfernen von Knotendaten aus NetCrunch. Es kann verwendet werden, um NetCrunch über Skripts und externe Anwendungen zu verwalten.
add-node
Den Knoten hinzufügen
Fügen Sie dem Atlas einen Knoten hinzu und aktivieren Sie die Überwachung, "name" oder "networkAddress" sind obligatorisch, die übrigen Eigenschaften sind optional.
POST /api/rest/2/nodes
cURL
curl --request POST --url "https://<netcrunch>/api/rest/2/nodes?api_key=<api key>" --header "Content-Type: application/json" --data "\"name\": \"<node name or address to add>\"}"
curl --request POST --url "http://<netcrunch>/api/rest/2/nodes?api_key=<api-key>&name=<node name or address to add>"
Node.js
const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/nodes', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, nodeData = { "name": "NewNode.ac.acme"
}; 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(nodeData)); req.end();
PowerShell
$url = "http://localhost/api/rest/2/nodes" $viewData = @{ name='NewNode.ac.acme' } $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/nodes' data = { "name": "NewNode.ac.acme" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url, data=data, headers=headers)
| Feldname | Beschreibung |
|---|---|
| name | DNS-Name |
| networkAddress | IP-Adresse |
| networkPrefixLength | Präfixlänge der Netzwerkmaske |
| displayName | Anzeigename für Knoten |
| organization | Name der Organisation. Es muss zu NetCrunch hinzugefügt werden, bevor es in der API verwendet wird |
| snmpManaged | wahr/falsch - die SNMP-Überwachung auf dem Knoten aktivieren |
| snmpProfile | Name des SNMP-Profils |
| snmpPort | SNMP-Port |
| snmpTimeout | SNMP-Überwachungszeitlimit in Millisekunden |
| snmpRetryCount | Anzahl der Wiederholversuche für SNMP-Überwachung |
| networkServices | Liste der zu überwachenden Netzwerkdienste |
| monitoringTime | Überwachungszeit in Minuten dargestellt |
| dependsOnNode | ID / Name / Adresse des Knotens, von dem dieser Knoten abhängt |
| identification | Knotenidentifikation zur Überwachung. Werte: 'default', 'ipAddress', 'dnsName', 'macAddress' |
| deviceType | Objekt, das den Gerätetyp darstellt |
| parentNode | ID / Name / Adresse des übergeordneten Knotens |
| children | Liste der Knoten-ID / des Namens / der Adresse, die die Kinder dieses Knotens darstellen |
| enabled | Überwachung dieses Knotens aktivieren/deaktivieren (wahr/falsch) |
| simplifiedMonitoring | Setzen Sie die vereinfachte Überwachung auf wahr/falsch |
| disabledFrom | Festlegen, um die Überwachung zu deaktivieren |
| disabledUntil | Festlegen, um die Überwachung zu deaktivieren |
| customFields | Objekt, das eine Liste von benutzerdefinierten Feldwerten darstellt |
| interfacesMonitoringEnabled | Aktivieren/Deaktivieren der Überwachung von Schnittstellen an diesem Knoten |
| snmpTrapPage | Snmp-Trap-Codepage |
| sysLogPage | Syslog-Codepage |
| organization | Name der Organisation für diesen Knoten |
| osMonitorType | Name des zu verwendenden OS-Monitors. Werte: 'auto', 'none', 'windows', 'macOS', 'linux', 'bsd', 'esx', 'solaris' |
Beispiel
{ "name": "admin.ad.acme", "networkAddress": "192.168.0.25", "networkPrefixLength": 24, "displayName": "My New Node", "organization": "My organization", "identification": "ipAddress", "deviceType": { "class": "Switch", "manufacturer": "3Com", "model": "LinkSwitch 2200" }, "dependsOnNode": "10.10.10.2", "children": [ "10.10.2.34", "10.10.2.35" ], "snmpManaged": true, "snmpProfile": "Default (read-write)", "snmpPort": 161, "snmpTimeout": 5000, "snmpRetryCount": 3, "interfacesMonitoringEnabled": true, "osMonitorType": "linux", "networkServices": [ { "name": "SSH", "timeout": 5000, "repeat": 3, "additionalRepeat": 0, "monitoringTime": 5 }, { "name": "CIFS/SMB", "isLeading": true } ], "simplifiedMonitoring": false, "enabled": true }
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
Ergebnis
Das Ergebnis enthält die ID des hinzugefügten Knotens.
{ "id": 1001 }
get-node-properties
Die Knoteneigenschaften abrufen
Rufen Sie die Eigenschaften des Knotens basierend auf dem Filter ab.
Liste aller verfügbaren Eigenschaften
GET/api/rest/2/nodes/<node>?properties=<filter>
cURL
curl --request GET --url "http://<netcrunch>/api/rest/2/nodes/192.168.0.25?api_key=<your-api-key>&properties=name,status"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/nodes/192.168.0.25?api_key=<your-api-key>&properties=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/nodes/192.168.0.25?api_key=<your-api-key>&properties=properties=name,status"
Python
import requests requests.get('http://localhost/api/rest/2/nodes/192.168.0.25?api_key=<your-api-key>&properties=properties=name,status')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | Knoten-ID, DNS-Name oder IP-Adresse |
| 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 |
| 412 | Fehlender oder ungültiger Parameter |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis des Beispiels
{ "id": 1001, "name": "admin.ad.acme", "dnsName": "admin.ad.acme", "networkAddress": "192.168.0.25", "networkPrefixLength": 24, "snmpComputerName": "admin.ad.acme", "snmpOsDescription": "Hardware: Intel64 Family 6 Model 26 Stepping 5 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 16299 Multiprocessor Free)", "snmpSysObjId": "1.3.6.1.4.1.311.1.1.3.1.1", "snmpLocation": "Development", "snmpAvailable": true, "snmpManaged": true, "snmpProfile": "Default (read-write)", "snmpPort": 161, "snmpTimeout": 5000, "snmpRetryCount": 3, "displayName": "My Node", "monitoringTime": "5", "networkServices": [ { "name": "SSH", "status": "Not Responding", "errorMessage": "Can't open connection" }, { "name": "CIFS/SMB", "isLeading": true, "status": "OK" } ], "dependsOnNode": { "nodeId": 1003, "name": "test.ad.acme", "networkAddress":"10.10.3.72", "dnsName":"test.ad.acme" }, "netBiosName": "ADMIN", "identification": "default", "deviceType":{ "class":"Server/Workstation", "os":"Windows Server", "version":"Windows 2012 R2 Server" }, "parentNode": { "nodeId": 1003, "name": "test.ad.acme", "networkAddress":"10.10.3.72", "dnsName":"test.ad.acme" }, "simplifiedMonitoring": false, "status": "OK", "avgResponseTime":10, "maxResponseTime":100, "alerts24h":{ "count":5, "critical":2, "warning":3, "unacknowledged":1 }, "lastAlert":{ "id":585266, "info":"Node Down", "serverity":"Critical", "time":"2018-10-09T06:15:15.000Z" }, "macAddress":"D89EF32B5ADD", "enabled":true, "disabledFrom":"2018-03-08T13:27:34.876Z", "disabledUntil":"2018-03-09T13:27:34.876Z", "addTime":"2018-02-08T13:27:34.876Z", "lastStatusChange":"2018-10-09T10:08:58.885Z", "issueCount": 2, "connectedToSwitch":{ "nodeId":1078, "interface":"Port-channel2", "port":464, "vlanId":999 }, "virtualization": { "type": "Hyper-V", "hostNodeId": 1023, "hostName": "virt-host.ad.acme", "dataCenter": "Master Data Center" }, "monitoringEngines":[ {"name":"nt", "name": "Windows", "enabled":true, "status":"OK", credentials: 'MyPassword', monitoringTime: 4}, {"name":"ntsvc", "name": "Windows Services", "enabled":true, "status":"unknown"}, {"name":"ntlog", "name": "Windows Event Log", "enabled":true, "status":"OK"} ], "children":[1506,1507], "pendingAlertsCount":0, "customFields":{ "Info 1":"Wacław", "Info 2":"Misiek", "Pick":"3", "Date Field":"1990-10-04T23:00:00.000Z" }, "interfacesMonitoringEnabled": true, "organizationalUnit": "Testing", "snmpTrapCodePage":4294967295, "sysLogCodePage":4294967295, "lastNote":null, "templateNode": { "nodeId": 1234, "name": "template", "networkAddress":"", "dnsName":"" }, "addressSpace":"", "sensors":[{ "UId":"Pending Reboot#1546607522658", "Status":"Unknown", "Changed":"2019-01-04T08:37:08.057Z", "Object":"MyObject", "Instance":"MyObject", "Name":"My Sensor", "Alerts":0, "CfgGroup":"sensors", "Message":"", "Enabled":true, "MonitoringTime":1, "Credentials":"<Use from Windows monitor>" }] }{ "id": 1001, "name": "admin.ad.acme", "dnsName": "admin.ad.acme", "networkAddress": "192.168.0.25", "networkPrefixLength": 24, "snmpComputerName": "admin.ad.acme", "snmpOsDescription": "Hardware: Intel64 Family 6 Model 26 Stepping 5 AT/AT COMPATIBLE - Software: Windows Version 6.3 (Build 16299 Multiprocessor Free)", "snmpSysObjId": "1.3.6.1.4.1.311.1.1.3.1.1", "snmpLocation": "Development", "snmpAvailable": true, "snmpManaged": true, "snmpProfile": "Default (read-write)", "snmpPort": 161, "snmpTimeout": 5000, "snmpRetryCount": 3, "displayName": "My Node", "monitoringTime": "5", "networkServices": [ { "name": "SSH", "status": "Not Responding", "errorMessage": "Can't open connection" }, { "name": "CIFS/SMB", "isLeading": true, "status": "OK" } ], "dependsOnNode": { "nodeId": 1003, "name": "test.ad.acme", "networkAddress":"10.10.3.72", "dnsName":"test.ad.acme" }, "netBiosName": "ADMIN", "identification": "default", "deviceType":{ "class":"Server/Workstation", "os":"Windows Server", "version":"Windows 2012 R2 Server" }, "parentNode": { "nodeId": 1003, "name": "test.ad.acme", "networkAddress":"10.10.3.72", "dnsName":"test.ad.acme" }, "simplifiedMonitoring": false, "status": "OK", "avgResponseTime":10, "maxResponseTime":100, "alerts24h":{ "count":5, "critical":2, "warning":3, "unacknowledged":1 }, "lastAlert":{ "id":585266, "info":"Node Down", "serverity":"Critical", "time":"2018-10-09T06:15:15.000Z" }, "macAddress":"D89EF32B5ADD", "enabled":true, "disabledFrom":"2018-03-08T13:27:34.876Z", "disabledUntil":"2018-03-09T13:27:34.876Z", "addTime":"2018-02-08T13:27:34.876Z", "lastStatusChange":"2018-10-09T10:08:58.885Z", "issueCount": 2, "connectedToSwitch":{ "nodeId":1078, "interface":"Port-channel2", "port":464, "vlanId":999 }, "virtualization": { "type": "Hyper-V", "hostNodeId": 1023, "hostName": "virt-host.ad.acme", "dataCenter": "Master Data Center" }, "monitoringEngines":[ {"name":"nt", "name": "Windows", "enabled":true, "status":"OK", credentials: 'MyPassword', monitoringTime: 4}, {"name":"ntsvc", "name": "Windows Services", "enabled":true, "status":"unknown"}, {"name":"ntlog", "name": "Windows Event Log", "enabled":true, "status":"OK"} ], "children":[1506,1507], "pendingAlertsCount":0, "customFields":{ "Info 1":"Hello", "Info 2":"Test", "Pick":"3", "Date Field":"1990-10-04T23:00:00.000Z" }, "interfacesMonitoringEnabled": true, "organizationalUnit": "Testing", "snmpTrapCodePage":4294967295, "sysLogCodePage":4294967295, "lastNote":null, "templateNode": { "nodeId": 1234, "name": "template", "networkAddress":"", "dnsName":"" }, "addressSpace":"", "sensors":[{ "UId":"Pending Reboot#1546607522658", "Status":"Unknown", "Changed":"2019-01-04T08:37:08.057Z", "Object":"MyObject", "Instance":"MyObject", "Name":"My Sensor", "Alerts":0, "CfgGroup":"sensors", "Message":"", "Enabled":true, "MonitoringTime":1, "Credentials":"<Use from Windows monitor>" }] }
get-node-property
Die Knoteneigenschaft abrufen
Rufen Sie den einzelnen Eigenschaftswert ab
GET/api/rest/2/nodes/<node identifier>/<property>
Liste aller verfügbaren Eigenschaften
cURL
curl --request GET --url "http://<netcrunch>/api/rest/2/nodes/1001/name?api_key=<api key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/nodes/1001/name?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/nodes/1001/name?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/nodes/1001/name?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | Knoten-ID, DNS-Name oder IP-Adresse |
| property | Name der abzurufenden Knoteneigenschaft. Der Eigenschaftsname kann einen Punkt enthalten, um die Untereigenschaft abzufragen. Zum Beispiel: lastAlert.id oder customFields.Info 1 |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
Das Ergebnis enthält die Eigenschaft und den Wert
{ "name": "email.ac.acme", }
get-list-of-maps-of-the-node
Die Liste der Karten des Knotens abrufen
Rufen Sie eine Liste der Ansichten des Knotens ab. Das Ergebnis wird als Array von JSON-Objekten zurückgegeben.
GET/api/rest/2/nodes/<node identifier>/maps
cURL
curl --request GET --url "http://<netcrunch>/api/rest/2/nodes/1001/maps?api_key=<api key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/nodes/1001/maps?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/nodes/1001/maps?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/nodes/1001/maps?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
[ {"id":75,"name":"Locations"}, {"id":219,"name":"Operating System Monitoring"}, {"id":1005,"name":"Monitoring Dependencies"}, {"id":1006,"name":"10.10.8.13/26"}, {"id":1007,"name":"Windows 10"}, {"id":1008,"name":"Workstations"} ]
get-list-of-monitoring-packs-of-the-node
Die Liste der Monitoring Packs des Knotens abrufen
Rufen Sie eine Liste der Monitoring Packs des Knotens ab. Die Liste wird als Array von JSON-Objekten zurückgegeben.
GET/api/rest/2/nodes/<node identifier>/policies
cURL
curl --request GET --url "http://<netcrunch>/api/rest/2/nodes/1001/policies?api_key=<api key>"
Node.js
const http = require('http'); http.get('http://localhost/api/rest/2/nodes/1001/policies?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/nodes/1001/policies?api_key=<your-api-key>"
Python
import requests requests.get('http://localhost/api/rest/2/nodes/1001/policies?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
[ {"id":64,"name":"Basic Windows Monitoring"}, {"id":78,"name":"Node Status"}, {"id":79,"name":"Service Status"} ]
set-node-properties
Die Knoteneigenschaften festlegen
Verwenden Sie eine einzelne Anforderung, um mehrere Eigenschaften des Knotens zu ändern oder festzulegen. Sie können eine JSON-Datei als Nutzdaten verwenden, um mehrere Eigenschaften gleichzeitig zu ändern
Liste aller verfügbaren Eigenschaften
PUT/api/rest/2/nodes/<node identifier>/<property>
cURL
curl --request PUT --url "http://<netcrunch>/api/rest/2/nodes/1001/name?api_key=<api key>&value=<value>"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/nodes/1001', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "NewNodeName.ac.acme" }; 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/nodes/1001" $viewData = @{ name='NewNodeName.ac.acme' } $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/nodes/1001' data = { "name": "NewNodeName.ac.acme" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, data=data, headers=headers)
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | Knoten-ID, DNS-Name oder IP-Adresse |
| property | Name der abzurufenden Knoteneigenschaft. Der Eigenschaftsname kann einen Punkt enthalten, um die Untereigenschaft abzufragen. Zum Beispiel: lastAlert.id oder customFields.Info 1 |
| value | Wert, der für das Feld festgelegt werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "status": "ok" }
set-node-property
Die Knoteneigenschaft festlegen
Ändern oder setzen Sie eine einzelne Eigenschaft des Knotens.
Liste aller verfügbaren Eigenschaften
PUT/api/rest/2/nodes/<node identifier>/<property>
cURL
curl --request PUT --url "http://<netcrunch>/api/rest/2/nodes/1001/name?api_key=<api key>&value=<value>"
Node.js
const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/nodes/1001', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "NewNodeName.ac.acme" }; 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/nodes/1001" $viewData = @{ name='NewNodeName.ac.acme' } $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/nodes/1001' data = { "name": "NewNodeName.ac.acme" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url, data=data, headers=headers)
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | Knoten-ID, DNS-Name oder IP-Adresse |
| property | Name der abzurufenden Knoteneigenschaft. Der Eigenschaftsname kann einen Punkt enthalten, um die Untereigenschaft abzufragen. Zum Beispiel: lastAlert.id oder customFields.Info 1 |
| value | Wert, der für das Feld festgelegt werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "id": 1001 }
manage-node-monitoring-state
Den Überwachungsstatus des Knotens verwalten
Aktivieren oder deaktivieren Sie die Knotenüberwachung, indem Sie den Wert auf Ein oder Aus setzen. Außerdem können Sie die Zeit festlegen, zu der der Knoten deaktiviert und erneut aktiviert werden soll
PUT/api/rest/2/nodes/<node identifier>/monitoring/<value>
cURL
curl --request PUT --url "http://<netcrunch>/api/rest/2/nodes/1001/monitoring/off?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"disabledFrom\": \"2018-03-08T13:27:34.876Z\", \"disabledUntil\": \"2018-03-09T13:27:34.876Z\"}"
Node.js
const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/nodes/1001/monitoring/off', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "disabledFrom": "2018-03-08T13:27:34.876Z", "disabledUntil": "2018-03-09T13:27:34.876Z" }; 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/nodes/1001/monitoring/off" $viewData = @{ disabledFrom='2018-03-08T13:27:34.876Z' disabledUntil='2018-03-09T13: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 Post -Body $body -Headers $hdrs
Python
import requests url = 'http://localhost/api/rest/2/nodes/1001/monitoring/off' data = { "disabledFrom": "2018-03-08T13:27:34.876Z" "disabledUntil": "2018-03-09T13:27:34.876Z" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url, data=data, headers=headers)
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | Knoten-ID, DNS-Name oder IP-Adresse |
| value | Werte "on"/"off" |
| disabledFrom | Datum, ab dem die Überwachung deaktiviert werden soll. Es wird ignoriert, wenn der Wert "on" ist |
| disabledUntil | Datum, bis zu dem die Überwachung deaktiviert werden soll. Es wird ignoriert, wenn der Wert "on" ist |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "status": "ok" }
add-network-service
Den Netzwerkdienst hinzufügen
Fügen Sie dem Knoten einen Netzwerkdienst hinzu. Knoten-ID und Netzwerkdienstname sind obligatorisch. Wenn keine anderen Parameter angegeben werden, werden die Programmvorgaben verwendet.
POST/api/rest/2/nodes/<node>/network-services
curl --request POST --url "https://localhost/api/rest/2/nodes/192.168.3.10/network-services?api_key=<your-api-key>&name=SSH"
Node.js
const http = require('http'); http.post('http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Method Post -Uri "http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH"
Python
import requests requests.post('http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| name | Name des zu überwachenden Dienstes |
| timeout | Es gibt die maximale Zeit in Millisekunden an, die NetCrunch auf eine Antwort warten soll |
| repeat | Anzahl der Anfragen zum Senden in einer einzelnen Prüfung |
| additionalRepeat | Anzahl zusätzlicher Prüfungen, wenn der Dienst nicht antwortet (Fehler, Timeout usw.) |
| monitoringTime | Zeit in Minuten eingestellt |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "status": "ok" }
set-network-services-parameters
Die Parameter für die Netzwerkdienste festlegen
Ändern Sie die Parameter des überwachten Netzwerkdienstes eines Knotens
PUT/api/rest/2/nodes/<node identifier>/network-services/<service>
cURL
curl --request PUT --url "https://localhost/api/rest/2/nodes/192.168.3.10/network-services/SSH?api_key=<your-api-key>&timeout=2000"
Node.js
const http = require('http'); http.put('https://localhost/api/rest/2/nodes/192.168.3.10/network-services/SSH?api_key=<your-api-key>&timeout=2000', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Method put -Uri "https://localhost/api/rest/2/nodes/192.168.3.10/network-services/SSH?api_key=<your-api-key>&timeout=2000"
Python
import requests requests.put('https://localhost/api/rest/2/nodes/192.168.3.10/network-services/SSH?api_key=<your-api-key>&timeout=2000')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| service | Name des zu ändernden Netzwerkdienstes |
| timeout | Es gibt die maximale Zeit in Millisekunden an, die NetCrunch auf eine Antwort warten soll |
| repeat | Anzahl der Anfragen zum Senden in einer einzelnen Prüfung |
| additionalRepeat | Anzahl zusätzlicher Prüfungen, wenn der Dienst nicht antwortet (Fehler, Timeout usw.) |
| monitoringTime | Zeit in Minuten eingestellt |
| isLeading | wahr/falsch, Leading Service ist ein Netzwerkdienst, der als einziger Dienst geprüft werden soll, wenn der Knoten DOWN ist |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "status": "ok" }
remove-network-service
Den Netzwerkdienst entfernen
Entfernen Sie die Netzwerkdienstüberwachung vom Knoten
DELETE/api/rest/2/nodes/<node identifier>/network-services/<service>
cURL
curl --request DELETE --url "https://localhost/api/rest/2/nodes/192.168.3.10/network-services/SSH?api_key=<your-api-key>&name=SSH"
Node.js
const http = require('http'); http.delete('http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Method delete -Uri "http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH"
Python
import requests requests.delete('http://localhost/api/rest/2/nodes/1001/network-services?api_key=<your-api-key>&name=SSH')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| service | Name des zu entfernenden Netzwerkdienstes |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |
Ergebnis
{ "status": "ok" }
set-custom-field-value
Benutzerdefinierten Feldwert festlegen
Legen Sie den Wert des benutzerdefinierten Felds auf einem Knoten fest. Das benutzerdefinierte Feld muss in NetCrunch definiert werden, um den Wert darauf festzulegen.
PUT/api/rest/2/nodes/<node>/custom-fields/<field>
cURL
curl --request PUT --url "https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>&value=My_Value"
Node.js
const http = require('http'); http.put('https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>&value=My_Value', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });
PowerShell
Invoke-RestMethod -Method put -Uri "https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>&value=My_Value"
Python
import requests requests.put('https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>&value=My_Value')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| field | Name des benutzerdefinierten Feldes, das gesetzt werden soll |
| value | Neuer Feldwert |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Feld nicht gefunden |
Ergebnis
{ "status": "ok" }
remove-custom-field-value
Benutzerdefinierten Feldwert entfernen
Entfernen Sie den benutzerdefinierten Feldwert aus dem Knoten.
DELETE/api/rest/2/nodes/<node identifier>/custom-fields/<field>
cURL
curl --request DELETE --url "https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>"
Node.js
const http = require('http'); http.delete('https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?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 -Method delete -Uri "https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>"
Python
import requests requests.delete('https://localhost/api/rest/2/nodes/192.168.3.10/custom-fields/Info%201?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| field | Name des zu entfernenden benutzerdefinierten Felds |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Feld nicht gefunden |
Ergebnis
{ "status": "ok" }
add-secondary-interface
Die Sekundäre Schnittstelle hinzufügen
Fügen Sie einem Knoten eine sekundäre Schnittstelle hinzu. Sowohl die Knoten von primären als auch von sekundären Schnittstellen müssen von NetCrunch überwacht werden.
POST/api/rest/2/nodes/<node identifier>/children/<child>
cURL
curl --request POST --url "https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>"
Node.js
const http = require('http'); http.post('https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?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 -Method Post -Uri "https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>"
Python
import requests requests.post('https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| child | ID, Name oder IP-Adresse eines Knotens, der hinzugefügt werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Kindknoten nicht gefunden |
Ergebnis
{ "status": "ok" }
remove-secondary-interface
Die Sekundäre Schnittstelle entfernen
Entfernen Sie den sekundären Schnittstellenknoten vom Knoten
DELETE/api/rest/2/nodes/<node identifier>/children/<child>
cURL
curl --request DELETE --url "https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>"
Node.js
const http = require('http'); http.delete('https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?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 -Method delete -Uri "https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>"
Python
import requests requests.delete('https://localhost/api/rest/2/nodes/192.168.3.10/children/192.168.3.20?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| child | ID, Name oder IP-Adresse eines Knotens, der entfernt werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Kindknoten nicht gefunden |
Ergebnis
{ "status": "ok" }
set-sensor-parameters
Die Sensorparameter einstellen
Stellen Sie die Parameter des Sensors ein
PUT/api/rest/2/nodes/<node>/sensors/<sensor>
curl --request PUT --url "https://localhost/api/rest/2/nodes/192.168.3.10/sensors/My%20Sensor?api_key=<your-api-key> --header "Content-Type: application/json" --data "{\"enabled\": true, \"credentials\": \"CredentialsProfile\", \"monitoringTime\": 5 }""
Node.js
const http = require('http'), querystring = require('querystring'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/nodes/192.168.3.10/sensors/' + querystring.escape('My Sensor') , headers: { "content-type": "application/json", "x-api-key": '<your-api-key>' } }, data = { "enabled": true, "credentials": "CredentialsProfile", "monitoringTime": 5 }; 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(data)); req.end();
PowerShell
$url = "http://localhost/api/rest/2/nodes/192.168.3.10/sensors/My%20Sensor" $data = @{ enabled=true, credentials='CredentialsProfile', monitoringTime=5 } $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/nodes/192.168.3.10/sensors/My%20Sensor' data = { "enabled": true, "credentials": "CredentialsProfile", "monitoringTime": 5 } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.put(url, data=data, headers=headers)
URL-Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse eines Knotens, der gelöscht werden soll |
| sensor | UID oder Name des zu ändernden Sensors. Es kann sich um eine Liste von Werten handeln, die durch Kommas getrennt sind |
Datenparameter
| Name | Beschreibung |
|---|---|
| enabled | wahr/falsch |
| credentials | Name des Profils der Anmeldedaten |
| monitoring time | Wert in Minuten |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Sensor nicht gefunden |
set-monitoring-engine-parameters
Die Parameter der Überwachungsengine festlegen
PUT/api/rest/2/nodes/<node>/monitoring-engines/<engine>
curl --request PUT --url "https://localhost/api/rest/2/nodes/192.168.3.10/monitoring-engines/Windows?api_key=<your-api-key> --header "Content-Type: application/json" --data "{\"enabled\": true, \"profileName\": \"CredentialsProfile\", \"monitoringTime\": 5}""
Node.js
const http = require('http'), querystring = require('querystring'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/nodes/192.168.3.10/monitoring-engines/Windows', headers: { "content-type": "application/json", "x-api-key": '<your-api-key>' } }, data = { "enabled": true, "profileName": "CredentialsProfile", "monitoringTime": 5 }; 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(data)); req.end();
PowerShell
$url = "http://localhost/api/rest/2/nodes/192.168.3.10/monitoring-engines/Windows" $data = @{ enabled=true, profileName='CredentialsProfile', monitoringTime=5 } $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/nodes/192.168.3.10/monitoring-engines/Windows' data = { "enabled": true, "profileName": "CredentialsProfile", "monitoringTime": 5 } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.put(url, data=data, headers=headers)
URL-Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse des Knotens |
| engine | ID oder Name der Überwachungsengine |
Datenparameter
| Name | Beschreibung |
|---|---|
| enabled | wahr/falsch |
| credentials | Name des Profils der Anmeldedaten |
| monitoringTime | Wert in Minuten. Auf null setzen, um den Standardwert zu verwenden (vom Knoten) |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Überwachungsengine nicht gefunden |
delete-sensor
Den Sensor löschen
DELETE/api/rest/2/nodes/<node>/sensors/<sensor>
curl --request DELETE --url "https://localhost/api/rest/2/nodes/192.168.3.10/sensors/My%20Sensor?api_key=<your-api-key>"
Node.js
const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/nodes/192.168.3.10/sensors/' + querystring.escape('My Sensor') , 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/nodes/192.168.3.10/sensors/My%20Sensor" $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/nodes/192.168.3.10/sensors/My%20Sensor' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url, headers=headers)
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse eines Knotens, der gelöscht werden soll |
| sensor | UID oder Name des zu ändernden Sensors. Es kann sich um eine Liste von Werten handeln, die durch Kommas getrennt sind |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten oder Sensor nicht gefunden |
delete-node
Den Knoten löschen
Entfernen Sie den Knoten aus dem Atlas
DELETE/api/rest/2/nodes/<node identifier>
curl --request DELETE --url "https://localhost/api/rest/2/nodes/192.168.3.15?api_key=<your-api-key>"
Node.js
const http = require('http'); http.delete('https://localhost/api/rest/2/nodes/192.168.3.15?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 -Method delete -Uri "https://localhost/api/rest/2/nodes/192.168.3.15?api_key=<your-api-key>"
Python
import requests requests.delete('https://localhost/api/rest/2/nodes/192.168.3.15?api_key=<your-api-key>')
Parameter
| Name | Beschreibung |
|---|---|
| node identifier | ID, Name oder IP-Adresse eines Knotens, der gelöscht werden soll |
Statuscodes
| Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Zugriff abgelehnt |
| 404 | Knoten nicht gefunden |