Skip to content

Docker container does not trigger script #27

@prevostc

Description

@prevostc

I use the script from the documentation (located in /var/www/lovebeat.sh):

#!/bin/bash

echo "Hello World"
env

And this config file (located in /var/www/lovebeat.sh):

[[alarms]]
name = "beatstash"
pattern = "beatstash.*"
[[alarms.alerts]]
script = "/var/www/lovebeat.sh"

Along with this docker command:

docker run --rm -it -p 8127:8127/udp -p 8127:8127/tcp -p 8082:8080 -v /etc/lovebeat.cfg:/etc/lovebeat.cfg -v /var/log/lovebeat:/var/log/lovebeat/ -v /var/www/lovebeat.sh:/var/www/lovebeat.sh boivie/lovebeat

And then when I send some events with an error timeout of 1 second, the script is not called:

$ docker run --rm -it -p 8127:8127/udp -p 8127:8127/tcp -p 8082:8080 -v /etc/lovebeat.cfg:/etc/lovebeat.cfg -v /var/log/lovebeat:/var/log/lovebeat/ -v /var/www/lovebeat.sh:/var/www/lovebeat.sh boivie/lovebeat
2016/07/12 13:22:05 INFO Lovebeat v0.8.0 started as host aa61fa6cfefe, PID 1, running from /data
2016/07/12 13:22:05 INFO Reading configuration file /etc/lovebeat.cfg
2016/07/12 13:22:05 INFO No metrics reporting configured
2016/07/12 13:22:05 ERROR Couldn't open 'lovebeat.db'
2016/07/12 13:22:05 INFO Created view 'all' (''), state = paused
2016/07/12 13:22:05 INFO VIEW 'all', 0: state paused -> ok
2016/07/12 13:22:05 INFO HTTP listening on :8080
2016/07/12 13:22:05 INFO UDP listening on :8127
2016/07/12 13:22:05 INFO TCP listening on :8127
2016/07/12 13:23:07 INFO SERVICE 'beatstash.heartbeat', state paused -> ok
2016/07/12 13:23:07 INFO SERVICE 'beatstash.heartbeat', err -1 -> 1000
2016/07/12 13:23:08 INFO SERVICE 'beatstash.heartbeat', state ok -> error
2016/07/12 13:23:08 INFO VIEW 'all', 1: state ok -> error
2016/07/12 13:23:32 INFO SERVICE 'beatstash.heartbeat', state error -> ok
2016/07/12 13:23:32 INFO VIEW 'all', 1: state error -> ok
2016/07/12 13:23:34 INFO SERVICE 'beatstash.heartbeat', state ok -> error
2016/07/12 13:23:34 INFO VIEW 'all', 2: state ok -> error

Logs from event-sender terminal (on the same machine):

$ curl -X POST -H 'application/x-www-form-urlencoded' 'http://localhost:8082/api/services/beatstash.heartbeat?err-tmo=1'
{}
$ # sleep 5 seconds
$ curl -X POST -H 'application/x-www-form-urlencoded' 'http://localhost:8082/api/services/beatstash.heartbeat?err-tmo=1'
{}

According to the documentation I should see something like this in the output logs:

2016/01/26 18:10:56 INFO ALARM 'example', 11: state ok -> error
2016/01/26 18:10:56 INFO Running alert script /path/to/script.sh
Hello World
LOVEBEAT_ALARM=example
LOVEBEAT_STATE=ERROR
LOVEBEAT_PREVIOUS_STATE=OK
LOVEBEAT_INCIDENT=11

But it's not the case.

I also checked script permissions and it's 0777 for now :

$ ls -la /var/www/lovebeat.sh 
-rwxrwxrwx 1 root root 35 Jul 12 14:25 /var/www/lovebeat.sh
$ /var/www/lovebeat.sh 
Hello World
LC_PAPER=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
[...] more env [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions