docker run -v /tmp/sensu:/var/lib/sensu -d --name sensu-backend -p 2380:2380 -p 3000:3000 -p 8080:8080 -p 8081:8081 sensu/sensu:latest sensu-backend start
Note 1: this will mount your hosts /tmp/sensu
directory into the container's /var/lib/sensu
. Replace the host directory as needed for your environment. I use /tmp/sensu
here to make it easy to clean up and get back to an unconfigured state.
Note 2: The sensu-backend service exposes all necessary ports to the local host so that you can interact with it as if it were running as a local service instead of a container.
docker run -v /tmp/sensu:/var/lib/sensu -d --name sensu-agent --link=sensu-backend sensu/sensu:latest sensu-agent start --backend-url ws://sensu-backend:8081 --subscriptions dev --cache-dir /var/lib/sensu
Note: this will mount your hosts '/tmp/sensu' directory into the container's /var/lib/sensu
and use it as the cache location in which to store downloaded assets. You will be able to look into the host's /tmp/sensu/
and see new asset directories added as you include additional assets in your check configurations.
sensuctl configure
Use the default user/password as and Sensu Backend URL: http://localhost:8080
sensuctl entity list
should have 1 entity corresponding to the sensu-agent container
Go to Bonsai: https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-cpu-checks Download the latest asset definition, choose platform: alpine and arch: amd64
sensuctl create -f ~/Downloads/sensu-plugins-sensu-plugins-cpu-checks-4.0.0-alpine-amd64.yml
You may need to adjust the file path depending on where your browser is configured to save Downloaded files and the version of the asset you selected.
type: CheckConfig
api_version: core/v2
metadata:
name: check-cpu-alpine
namespace: default
spec:
check_hooks: null
command: check-cpu.rb
env_vars: null
handlers: []
high_flap_threshold: 0
interval: 60
low_flap_threshold: 0
output_metric_format: ""
output_metric_handlers: []
proxy_entity_name: ""
publish: true
round_robin: false
runtime_assets:
- sensu-plugins-cpu-checks
stdin: false
subdue: null
subscriptions:
- dev
timeout: 20
ttl: 0
Wait a minute for the check to execute
sensuctl event list
check event should be in a critical state should error output because we have not installed the ruby runtime environment yet.
Go to Bonsai: https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime Download the latest version of asset definition, choose platform: alpine and arch: amd64
sensuctl create -f ~/Downloads/sensu-sensu-ruby-runtime-0.0.5-alpine-amd64.yml
sensuctl edit check check-cpu-alpine
Final check defiition should look like this:
type: CheckConfig
api_version: core/v2
metadata:
name: check-cpu-alpine
namespace: default
spec:
check_hooks: null
command: check-cpu.rb
env_vars: null
handlers: []
high_flap_threshold: 0
interval: 60
low_flap_threshold: 0
output_metric_format: ""
output_metric_handlers: []
proxy_entity_name: ""
publish: true
round_robin: false
runtime_assets:
- sensu-ruby-runtime
- sensu-plugins-cpu-checks
stdin: false
subdue: null
subscriptions:
- dev
timeout: 20
ttl: 0
Wait a minute and review the event list again. Check should now be operating correctly.
docker stop sensu-agent
docker rm sensu-agent
docker stop sensu-backend
docker rm sensu-backend
You can also choose to clean out the /tmp/sensu
directory. if you re-run this process again without cleaning this directory out, sensu containers will re-use resources configured in prior run.