pass the original stdin to the program called by sifter
alisade opened this issue · 7 comments
pass the original stdin to the program called by sifter, we use the 'Value' field in there.
I'm already doing that with the event watch - it passes the Payload
along.
Did you want the key
watch to do the same thing?
Yes please.
Best Regards,
Ali
On Aug 29, 2016, at 15:32, darron froese notifications@github.com wrote:
I'm already doing that with the event watch - it passes the Payload along.
Did you want the key watch to do the same thing?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Hi darron
Im using sifter with consul watch for event and it doesnt seem like the original stdin is passed into the program
Im firing events like so
curl -v -X PUT -d "servicetoggle service:mongo command:start" "http://localhost:8500/v1/event/fire/testme?node=10.112.123.4&service=mongo--mtq3ntk4nzcxo"
Consul watch command:
consul watch -type=event -name=testme /usr/local/bin/sifter event -d true -m='dsifter' -e 'testme.sh'
I see following output for sifter
2016/10/11 22:58:49 key='sifter/event/testme/ip-10-112-123-4' value='229'
2016/10/11 22:58:49 exec='payload' payload='c2VydmljZXRvZ2dsZSBzZXJ2aWNlOm1vbmdvIGNvbW1hbmQ6c3RhcnQ='
2016/10/11 22:58:49 location='complete' elapsed='14.507521ms' watch='event' exec='/root/testme.sh' ltime='229'
testme.sh
#!/bin/bash
read a
echo $a > /log/consul_watcher.log
The consul_watcher.log shows nothing
Am i missing something here?
Hi @darron
Sorry , please disreard my previous comment . I didnt realize how sifter worked, as we have complete bash solution to handle the ltime issue but i'd rather use this.
@mg03 I see something similar, just getting empty messages. Not sure what I am missing. Its unclear how did you solved your problem.
Update:
I see sifter reading the events and logging them to /var/log/messages but how am I supposed to read the payload in my script.
My handler script has the following
#!/bin/bash -v
message=$(cat)
echo $message
echo $message >> /tmp/watch.log
I see blank lines appearing in watch.log.
Figured out. The payload is passed as a argument to the script. So I was able to collect it using $1.
The following solved my problem
#!/bin/bash -v
message=$1
echo $message
echo $message >> /tmp/watch.log
This still does not work for me. I am using a "key" type watch.
#!/bin/bash -v
message=$1
echo $message
echo $message >> /tmp/watch.log
echo "I am testing" >> /tmp/watch.log
I can see the "I am testing" string in watch.log file but not the payload. Everything is getting logged duly under /var/log/messages though. Am I missing anything ?