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

pass the original stdin to the program called by sifter #12

Open
alisade opened this issue Aug 29, 2016 · 7 comments
Open

pass the original stdin to the program called by sifter #12

alisade opened this issue Aug 29, 2016 · 7 comments

Comments

@alisade
Copy link

alisade commented Aug 29, 2016

pass the original stdin to the program called by sifter, we use the 'Value' field in there.

@darron
Copy link
Owner

darron commented Aug 29, 2016

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?

@alisade
Copy link
Author

alisade commented Aug 30, 2016

Yes please.

Best Regards,
Ali

On Aug 29, 2016, at 15:32, darron froese [email protected] 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.

@mg03
Copy link

mg03 commented Oct 11, 2016

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?

@mg03
Copy link

mg03 commented Oct 12, 2016

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.

@gamefundas
Copy link

gamefundas commented Jan 7, 2017

@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.

@gamefundas
Copy link

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

@rashcuva
Copy link

rashcuva commented Sep 18, 2017

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 ?

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

No branches or pull requests

5 participants