Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-915

Monitor external script set no command line arguments

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • 1.3.0
    • N/A
    • maxadmin, Monitor
    • None

    Description

      The command line arguments not set and I need it in the external script.

      maxscale.cnf

      [Multi-Master Monitor]
      type=monitor
      module=mmmon
      servers=GRAANTOETS,PHPDEV,PHPPRD,201W01,202W01
      user=maxscale
      passwd=xxx
      monitor_interval=1000
      script=/home/mail_to_admin.sh --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      events=master_down,master_up, slave_up, server_down ,server_up,lost_master,lost_slave,new_master,new_slave,server_down,server_up,synced_down,synced_up
      disable_master_role_setting=true

      and mail_to_admin.sh

      #!/bin/bash

      failover_master.sh

      ARGS=$(getopt -o '' --long 'event:,initiator:,nodelist:' – "$@")
      eval set – "$ARGS"

      while true; do
      case "$1" in
      --event)
      shift;
      event=$1
      shift;
      ;;
      --initiator)
      shift;
      initiator=$1
      shift;
      ;;
      --nodelist)
      shift;
      nodelist=$1
      shift;
      ;;
      --)
      shift;
      break;
      ;;
      esac
      done

      candidate=echo "$nodelist" | awk -F':' '

      {print $1}'
      maxscale_host=echo "$initiator" | awk F'' '{print $5}'
      maxscale_host=echo "$maxscale_host" | awk -F':' '{print $1}

      '

      echo 'candidate' $candidate >> /home/output.log
      echo 'maxscale_host' $maxscale_host >> /home/output.log

      output.log

      candidate $NODELIST
      maxscale_host
      candidate $NODELIST
      maxscale_host
      candidate $NODELIST
      maxscale_host
      candidate $NODELIST
      maxscale_host
      candidate $NODELIST
      maxscale_host
      candidate $NODELIST

      It looks like maxscale called the script but set the arguments to a string that is "$NODELIST"

      Here is another test:

      maxscale -d
      Info : MaxScale will be run in the terminal process.
      Configuration file : /etc/maxscale.cnf
      Log directory : /var/log/maxscale
      Data directory : /var/lib/maxscale/data
      Module directory : /usr/lib/maxscale
      Service cache : /var/cache/maxscale

      in the log:

      2016-10-13 08:45:38 notice : Initialise the Multi-Master Monitor module V1.1.1.

      2016-10-13 08:45:38 notice : Loaded module mmmon: V1.1.1 from /usr/lib/maxscale/libmmmon.so

      MaxScale> list servers
      Servers.
      --------------------------------------------------------------------
      Server | Address | Port | Connections | Status
      --------------------------------------------------------------------
      GRAANTOETS | 172.16.3.xxx | 3306 | 0 | Master, Running
      201W01 | 172.17.5.xxx | 3306 | 0 | Master, Running
      202W01 | 172.20.7.xxx | 3306 | 0 | Master, Running
      PHPDEV | 172.16.2.xxx | 3306 | 0 | Master, Running
      PHPPRD | 172.16.2.xxx | 3306 | 0 | Master, Running
      --------------------------------------------------------------------

      When I stop 201w01 the script is called with the following:

      list servers
      Servers.
      --------------------------------------------------------------------
      Server | Address | Port | Connections | Status
      --------------------------------------------------------------------
      GRAANTOETS | 172.16.3.xxx | 3306 | 0 | Master, Running
      201W01 | 172.17.5.xxx | 3306 | 0 | Master, Running
      202W01 | 172.20.7.xxx | 3306 | 0 | Down
      PHPDEV | 172.16.2.xxx | 3306 | 0 | Master, Running
      PHPPRD | 172.16.2.xxx | 3306 | 0 | Master, Running
      --------------------------------------------------------------------

      I tested echo $# $@ >> my_debug.log :

      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST
      3 --event=$EVENT --initiator=$INITIATOR --nodelist=$NODELIST

      The script is called by not logged in the maxscale log file, i dont know if I'm doing something wrong because I'm new to maxscale.

      Attachments

        Activity

          People

            markus makela markus makela
            Scoprshn Shaun Adlam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.