Use WebSockets to listen to element notifications
You can use WebSockets to listen to notifications about elements stored in the Management Server database.
To monitor elements, you subscribe to status notifications. When the Management Server receives new information about the elements to which you have subscribed, you receive new status entries.
Steps
Example
For example, when you send this command to subscribe to notifications about a policy-based VPN tunnel endpoint:
{"element":"https://http://localhost:8082/7.1/elements/vpn/5/tunnels/MiM1OQ==/endpoints/MSMxMTQ="}
You receive this response:
{"success":"Subscribed for status","subscription_id":0}
{"status":{"status":{"health_in_percent":71,"jitter_in_ms":3,"latency_in_ms":71,"monitoring_state":"READY",
"monitoring_status":"OK","name":"Corporate VPN","packet_loss_in_permyriad":361,
"result":[{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjU=",
"name":"Gateway Tunnel Helsinki VPN Gateway-Paris VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjc=","name":"Gateway Tunnel Helsinki VPN Gateway-Tunis VPN Gateway",
"type":"gateway_tunnel"},{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjQ=",
"name":"Gateway Tunnel Helsinki VPN Gateway-Moscow VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjA=","name":"Gateway Tunnel Helsinki VPN Gateway-London VPN Gateway",
"type":"gateway_tunnel"},{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTgjNTk=",
"name":"Gateway Tunnel Beijing VPN Gateway-Helsinki VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjM=","name":"Gateway Tunnel Helsinki VPN Gateway-Milan VPN Gateway",
"type":"gateway_tunnel"},{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTYjNTk=",
"name":"Gateway Tunnel Atlanta VPN Gateway-Helsinki VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/MiM1OQ==","name":"Gateway Tunnel VPN Client-Helsinki VPN Gateway",
"type":"gateway_tunnel"},{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTUjNTk=",
"name":"Gateway Tunnel Algiers VPN Gateway-Helsinki VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjI=","name":"Gateway Tunnel Helsinki VPN Gateway-Mexico City VPN Gateway",
"type":"gateway_tunnel"},{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjY=",
"name":"Gateway Tunnel Helsinki VPN Gateway-Riyadh VPN Gateway","type":"gateway_tunnel"},
{"href":"http://localhost:8082/7.1/elements/vpn/5/tunnels/NTkjNjE=","name":"Gateway Tunnel Helsinki VPN Gateway-Madrid VPN Gateway",
"type":"gateway_tunnel"}],"traffic_in_bits_per_sec":1881231412,"vpn_status_code":"Idle"}},
"subscription_id":0}
When you send this command to subscribe to notifications about a engine node:
{"element":"http://localhost:8082/7.1/elements/single_fw/1649/firewall_node/1650"}
You receive this response:
{"success":"Subscribed for status","subscription_id":5}
{"status":{"status":{"monitoring_state":"READY","monitoring_status":"OK","name":"Plano node 1"}},"subscription_id":5}