Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container does not trigger script #27

Open
prevostc opened this issue Jul 12, 2016 · 4 comments
Open

Docker container does not trigger script #27

prevostc opened this issue Jul 12, 2016 · 4 comments

Comments

@prevostc
Copy link

prevostc commented Jul 12, 2016

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 [...]
@boivie
Copy link
Owner

boivie commented Jul 12, 2016

I see that the docker image hasn't been updated to the version that supports this. It's still on 0.8, while we have released 1.0 now.

I'll do that this evening.

Sorry about that. The binaries found in Github's releases are up to date, though.

@prevostc
Copy link
Author

Ok, noted, thanks.

Can you take a look at http://lovebeat.readthedocs.io/, I think this doc is outdated too.

boivie added a commit that referenced this issue Jul 13, 2016
We had to base them on debian now that they are not completely
statically compiled. This something we have to investigate in
order to be able to run completely on busybox as before.

Built using:

 docker build -t boivie/lovebeat:latest -t boivie/lovebeat:1.0.1 .

Available at:
 https://hub.docker.com/r/boivie/lovebeat/tags/

closes #26, #27
@boivie
Copy link
Owner

boivie commented Jul 13, 2016

I've updated the docker images now.

Could you please tell me what's outdated in the docs and I'll update it

@prevostc
Copy link
Author

The alerter configuration example does not work: http://lovebeat.readthedocs.io/en/latest/alerters.html

For script alerter it states:

[[alarms]]
name = "example"
pattern = "test.*"
alerts = ["test-alert"]

[[alarms.alerts]]
script = "/path/to/script.sh"

Which triggers an error.

The documentation in master is up to date but readthedocs.io isn't.

https://github.com/boivie/lovebeat/blob/master/docs/alerters.rst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants