User Modules are a way for you to create and deploy your own custom services to your Canaries. Once deployed, your Canary will listen on the specified port, and once hit, will behave in the way you want it to.
Creating your custom service is quick and can be easily done by following the below steps.
Step 1: Setup environment
Setup and activate python virtual environment:
/Users/canary/Work/usermodules/
virtualenv usermodenv
source usermodenv/bin/activate
Next, install canaryusermodule python module:
Caveat!
As of v0.31.0, the python wheel format no longer includes the metadata.json file. The Canary expects this, so the user module will fail to load. This is easily fixed by installing the 0.30.0 version of wheel in your virtual env.
/Users/canary/Work/usermodules/
pip install canaryusermodule wheel==0.30.0
Step 2: Generate test module and install into virtual env
/Users/canary/Work/usermodules/
usermodgen HelloTest
Install test module into virtual env:
/Users/canary/Work/usermodules/
cd hellotest
python setup.py develop
Step 3: Dev and test module
Test with and watch raw json logs in foreground:
/Users/canary/Work/usermodules/hellotest
opencanaryd --usermodule
Hack!, hack!, hack! (Repeat above as desired)
Step 4: (Optional) Clean Up Test Module
delete test user module from virtual environment:
/Users/canary/Work/usermodules/hellotest
pip uninstall -y hellotest
Step 5 - Build and upload
Build test module:
/Users/canary/Work/usermodules/hellotest
./build.sh
The usermodule will be the *.whl in dist. Upload this to canary.
/Users/canary/Work/usermodules/hellotest
./dist/HelloTest-1.0-py2-none-any.whl
In order to upload your user module you will need to boot your device into configuration mode.