General documentation: https://oliver-zehentleitner.github.io/unicorn-binance-websocket-api
Module documentation: https://oliver-zehentleitner.github.io/unicorn-binance-websocket-api/unicorn_binance_websocket_api.html#module-unicorn_binance_websocket_api.unicorn_binance_websocket_api_restserver
Icinga Plugin: https://exchange.icinga.com/LUCIT/check_lucit_collector
You have two possibilities to provide ICINGA2 the needed data, the first is, you connect it with the check_command through
`binance_websocket_api_manager.start_monitoring_api()`. This creates a restful api on http://127.0.0.1:64201/status/icinga/0.1.0 and with the icinga plugin ‘check_lucit_collector.py‘ you can report the current status to ICINGA2.
The second possibility is, to get the plain status data via ‘
binance_websocket_api_manager.get_monitoring_status_plain()‘ and to build a specific check for your application. If you are planing to build a new plugin for an other monitoring software, please fork our project on github and build a method on top of ‘get_monitoring_status_plain()’ like ‘get_monitoring_status_icinga()’ in ‘./unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py’ and create a pull request. We would appreciate it!
In this “howto” we are going to handle the first method, which is quiet easy!
We assume you have a ready script with one or more running websockets, than you just have to add this to your code:
If you dont have a ready script, download “example_monitoring.py“.
That was the coding part 🙂
The next step is to learn ICINGA2 to connect with the monitoring API of the UNICORN Binance WebSocket API Manager instance.
binance_websocket_api_manager.start_monitoring_api()‘ without any parameter starts a restful api server on http://127.0.0.1:64201 (redirect to WIKI) and on http://127.0.0.1:64201/status/icinga
is the resource for the check_command. So the check_command needs to be
on the same host. If you want to use the check_command from a remote
host you have 2 possibilities. One is to start the monitoring API server
But then the service is also available over the network!
The second and in general more secure way is, to use the ICINGA2 agent! To do this, connect the ICINGA2 server and the “websocket server” with the command ‘icinga2 node wizard’. There are several blogs handling this topic ask google or use https://www.techrepublic.com/article/how-to-set-up-icinga2-agent-monitoring/.
Download ‘check_binance_websocket_api_manager’ from https://exchange.icinga.com/LUCIT/check_lucit_collector/releases or https://github.com/LUCIT-Development/check_lucit_collector.py to the system of your choice and put it to the plugin direcotory. On debian/ubuntu it should be ‘/usr/lib/nagios/plugins’ and make it execute able with ‘sudo chmod +x ./check_lucit_collector.py’ and make a test run. If the check_command and the binance websocket app are on the same server the check_command can use the default value (127.0.0.1) so the command is simple ‘./check_lucit_collector.py’ and should return someting like:
BINANCE WEBSOCKETS (binance.com) - WARNING: O:18/R:0/C:0/S:0 - Update 1.3.3 available! | receives_per_second=713;;;0 kb_per_second=513;;;0 received_mb=6385;;;0 stream_buffer_mb=0;;;0 stream_buffer_items=3;;;0 reconnects=0;;;0
If this works fine, then you can go ahead and configure ICINGA2.
It doesnt matter if you use files or the Icinga2 Director Module to configure ICINGA2 objects, the first step is creating a new command template (director -> commands -> command templates). The command type is “Plugin Check Command”, name it how you like it, but common would be something like “check_lucit_collector” and the command has to be ‘./check_lucit_collector.py’, then save it.
Then create a “command” in (director -> commands -> command). Command type is “Plugin Check Command”, command name is your choice and imports should be the template you created before.
Then create a service template in (director -> services -> templates)… now it depends very on your general structure and you should be able to overtake further confguration from here.
Good luck and have fun!