Just learning all about st2!


(Rick Kauffman) #1

I have a rule “examples.sample_rule_file_watch” and it is enabled. It’s all default. It’s watching a file called “/tmp/st2_test”.

When I echo something out to that file, and then look at st2 execution list, there is no indication that anything happened?

I keep hearing about “Stanley” do I need to be logged in as that user?..clueless…thanks!


#2

Please post your rule here so we can take a look.

Have you used the st2-rule-tester tool to test your rule?
Is there anything in the StackStorm logs that indicates StackStorm saw the file change (the StackStorm logs are different than the execution history)?

Does the /tmp/st2_test file already exist when you start StackStorm (st2ctl restart --register-all or st2ctl start --register-all), or do you create it when you echo to it?

Here’s a few other hopefully helpful links you may have read already:


(Rick Kauffman) #3

Here is the rule:

[root@ricks rick]# st2 rule get examples.sample_rule_file_watch
+-------------+--------------------------------------------------------------+
| Property    | Value                                                        |
+-------------+--------------------------------------------------------------+
| id          | 5c33c63fa3fa66d1e29b6e92                                     |
| uid         | rule:examples:sample_rule_file_watch                         |
| ref         | examples.sample_rule_file_watch                              |
| pack        | examples                                                     |
| name        | sample_rule_file_watch                                       |
| description | Sample rule custom trigger type - add a file to be watched   |
|             | by file_watch_sensor in linux pack.                          |
| enabled     | True                                                         |
| action      | {                                                            |
|             |     "ref": "core.local",                                     |
|             |     "parameters": {                                          |
|             |         "cmd": "echo "{{trigger}}""                          |
|             |     }                                                        |
|             | }                                                            |
| context     | {                                                            |
|             |     "user": "st2admin"                                       |
|             | }                                                            |
| criteria    |                                                              |
| tags        |                                                              |
| trigger     | {                                                            |
|             |     "type": "linux.file_watch.line",                         |
|             |     "ref": "linux.72127a9b-4a8e-4a14-8711-4774304d7088",     |
|             |     "parameters": {                                          |
|             |         "file_path": **"/tmp/st2_test"**                         |
|             |     }                                                        |
|             | }                                                            |
| type        | {                                                            |
|             |     "ref": "standard",                                       |
|             |     "parameters": {}                                         |
|             | }                                                            |
+-------------+--------------------------------------------------------------+

I echo something out to the file /tmp/st2_test and I can cat the file and see what I did but st2 execution list doesn’t change. Do I need to do a st2 auth first?

I did a st2ctl reload

Thanks!


#4

Please use Markdown formatting to format any file contents here - it makes it much easier to read.

Also, when you are echoing to the /etc/st2_test file, are you overwriting the file (echo Hello world > /etc/st2_test) or are you appending to the file (echo Hello world >> /etc/st2_test)?


#5

Does the st2 user have permissions to read that file?


(Lindsay Hill) #6

You’re probably hitting this bug - [st2reactor] Issue about validation fail before dispatching trigger,Trigger type with reference "linux.cd875f82-58d6-47ff-9eff-11bd81493bf7" doesn't exist in the database · Issue #4486 · StackStorm/st2 · GitHub. There’s a workaround in the comments there.

See the PR that fixes it here: Fix a bug with trigger payload validation in linux.FileWatchSensor sensor by Kami · Pull Request #4491 · StackStorm/st2 · GitHub


(Rick Kauffman) #7

yes, appending…looks like I need to figure out what markdown is as well


(Rick Kauffman) #8

I do a st2 login with st2admin and a password. I don’t know what user is trying to write to the file but when I run the echo command it appends what I echo to the file…thanks!


(Rick Kauffman) #9

bummer, thanks! I’ll have a look.


(Lindsay Hill) #10

At least the workaround is easy enough - just disable that validation & restart st2. Won’t matter for a test system.