-
Notifications
You must be signed in to change notification settings - Fork 60
Web hooks
Web hooks are HTTP POST calls that can be automatically executed by Netshot when some events occur.
This feature was introduced with version 0.16.
As of Netshot 0.16:
- POST is only supported method.
- Possible triggers are:
- After device snapshot
- After JS script executed on device
- After diagnostics performed on device
- The content of the task can be posted in either XML (
application/xml
) or JSON (application/json
).
Go to the Admin tab, Web Hooks and click Add... button.
The execution of the hooks can be monitored by looking at the main log file, /var/log/netshot/netshot.log
by default.
Messages such as the following should appear:
2021-01-23 14:47:13,601 INFO [QuartzScheduler_Worker-1] TaskJob: Result of post-task hook 'Test Hook' after task 118 is: HTTP response code 200
For a post-task hook, the content of the task will be posted.
Here is an example in JSON format:
{
"type": ".TakeSnapshotTask",
"author": "admin",
"changeDate": 1611412533000,
"comments": "",
"creationDate": 1611412516384,
"debugEnabled": false,
"executionDate": 1611412517443,
"id": 122,
"log": "[INFO] Snapshot task for device router1 (192.168.1.101).\n[DEBUG] Authentication failed 192.168.1.101/0:0 using SSH credential set DEVICESPECIFIC-ee93955a-03d9-4b4e-99b0-90462c33e4a5.\n[TRACE] Will try SSH credentials SSH admin/netshot.\n[DEBUG] Authentication failed using SSH credential set SSH admin/netshot.\n[TRACE] Will try SSH credentials SSH admin/admin.\n[INFO] Connected using SSH to 192.168.1.101:0 using credentials SSH admin/admin.\n[INFO] The configuration hasn't changed. Not storing a new one in the DB.\n",
"scheduleReference": 1611412516224,
"scheduleType": "ASAP",
"status": "SUCCESS",
"target": "router1",
"device": {
"autoTryCredentials": true,
"changeDate": 1611411940000,
"comments": "",
"contact": "",
"createdDate": 1609456546507,
"creator": "admin",
"specificCredentialSet": {
"type": "SSH",
"id": 9,
"name": "DEVICESPECIFIC-ee93955a-03d9-4b4e-99b0-90462c33e4a5",
"mgmtDomain": null,
"deviceSpecific": true
},
"driver": "CiscoIOS12",
"eolDate": null,
"eolModule": null,
"eosDate": null,
"eosModule": null,
"family": "Cisco CSR1000V",
"location": "Virtual DC",
"mgmtAddress": {
"prefixLength": 0,
"addressUsage": "PRIMARY",
"ip": "192.168.1.101"
},
"name": "router1",
"networkClass": "ROUTER",
"serialNumber": "***",
"softwareLevel": "UNKNOWN",
"softwareVersion": "15.5(3)S7b",
"status": "INPRODUCTION",
"sshPort": 0,
"telnetPort": 0,
"connectAddress": null,
"realDeviceType": "Cisco IOS and IOS-XE",
"endOfLife": false,
"endOfSale": false,
"credentialSetIds": [
5,
3
],
"compliant": true
},
"automatic": false,
"dontRunDiagnostics": true,
"dontCheckCompliance": true,
"taskDescription": "Device snapshot",
"deviceId": 4,
"nextExecutionDate": null,
"repeating": false
}
By default, when the hook is triggered, if the URL is https one, the server certificate will be validated using the Java system TrustStore.
On Debian systems using OpenJDK, this is file /etc/ssl/certs/java/cacerts
which is automatically generated based on installed CAs by ca-certificates-java package.
You can also disable SSL certificate verification on the hook but this is not advised.