[MXS-2791] Special arguments are not passed to MaxScale's monitor script Created: 2019-12-09  Updated: 2020-08-25  Resolved: 2019-12-10

Status: Closed
Project: MariaDB MaxScale
Component/s: Monitor
Affects Version/s: 2.3.15, 2.4.4
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Johan Wikman
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to MXS-121 Ability to launch external scripts fr... Closed
relates to MXS-1445 Add script variables Closed
relates to MXS-2792 Documentation for MaxScale's monitor ... Closed

 Description   

MaxScale allows users to set a script parameter for all monitors. When this parameter is set, MaxScale will execute the specified script whenever the cluster changes in some way. MaxScale is supposed to pass special arguments to the script, and these special arguments are supposed to contain information about the cluster change.

https://mariadb.com/kb/en/mariadb-maxscale-24-common-monitor-parameters/#script

Unfortunately, MaxScale does not currently pass the special arguments to the script at all.

To test this, we can create a very simple script:

$ cat /tmp/test.sh
#!/usr/bin/env bash
 
echo "Script arguments: $@"

And then we can configure MaxScale to use the script:

[Galera-Monitor]
type=monitor
module=galeramon
servers=C1N1,
        C1N2,
        C1N3
user=maxscale
password=password
monitor_interval=10000
script=/tmp/test.sh

When the cluster changes, MaxScale does execute the script, but we can see that no arguments are passed to it:

2019-12-09 17:07:35   notice : Server changed state: C1N3[172.30.0.126:3306]: master_down. [Master, Synced, Running] -> [Down]
2019-12-09 17:07:35   info   : Executing command '/tmp/test.sh' in process 2179
2019-12-09 17:07:35   notice : /tmp/test.sh: Script arguments:
2019-12-09 17:07:35   notice : Executed monitor script '/tmp/test.sh' on event 'master_down'
2019-12-09 17:07:35   notice : Master switch detected: lost a master and gained a new one



 Comments   
Comment by Geoff Montee (Inactive) [ 2019-12-10 ]

It looks like the problem is that the value provided to the script parameter needs to include the relevant arguments. For example, something like this works:

[Galera-Monitor]
type=monitor
module=galeramon
servers=C1N1,
        C1N2,
        C1N3
user=maxscale
password=password
monitor_interval=10000
script=/tmp/test.sh --initiator=$INITIATOR --parent=$PARENT --children=$CHILDREN --event=$EVENT --node_list=$NODELIST --list=$LIST --master_list=$MASTERLIST --slave_list=$SLAVELIST --synced_list=$SYNCEDLIST

Generated at Thu Feb 08 04:16:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.