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

Trigger for shell script message #3

Open
khurshid-alam opened this issue Jun 16, 2016 · 3 comments
Open

Trigger for shell script message #3

khurshid-alam opened this issue Jun 16, 2016 · 3 comments

Comments

@khurshid-alam
Copy link

I use logger or systemd-cat to send script output to systemd journald. For example a script named myscript99

#!/bin/bash
exec 1> >(logger -s -t $(basename $0)) 2>&1
echo "my pants are on fire!"

which can be filtered by journalctl using:

journalctl -t "myscript99"

I want to filter message both by identifier and message. My rule file looks like this:

[Rule]
trigger=~/.http_post.sh
[Filter]
SYSLOG_IDENTIFIER=myscript99
MESSAGE=*"fire"*

But it doesn't trigger anything. How does pattern matching work in this case?

@jjk-jacky
Copy link
Owner

You need to use ?= to enable pattern matching; So you probably want your
MESSAGE condition to be written as such:
MESSAGE?=fire

Also I think your trigger isn't gonna work because this isn't a shell,
there's no expansion, so you need to specify an actual path,
e.g: /home/user/.http_post.sh

@khurshid-alam
Copy link
Author

khurshid-alam commented Jun 17, 2016

Thanks. I will try. One other question: Is there any way I can pass MESSAGE and SYSLOG_IDENTIFIER t o my script (http_post.sh) as arguments?

@jjk-jacky
Copy link
Owner

Sure: use $MESSAGE and $SYSLOG_IDENTIFIER -- See man page for more.

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