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

Documentation for MaxScale's monitor script is incomplete

    XMLWordPrintable

    Details

    • Sprint:
      MXS-SPRINT-96, MXS-SPRINT-97

      Description

      The documentation for MaxScale's monitor script seems to be incomplete:

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

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

      It is missing the following items:

      1.) It is missing the $CREDENTIALS argument:

      https://github.com/mariadb-corporation/MaxScale/blob/maxscale-2.4.4/server/core/monitor.cc#L1086

      2.) It is missing a working example script:

      The MariaDB Monitor page for MaxScale 2.3 currently has an example script:

      https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-monitor/#example-1-monitor-script

      However, this script doesn't even work. It results in an error like this:

      line 5: ${$2/.*=/}: bad substitution
      

      We should probably add a working example to the "Common Monitor Parameters" page.

      For example, if we had the following monitor configured:

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

      Then the following script makes a good example:

      #!/usr/bin/env bash
       
      initiator=""
      parent=""
      children=""
      event=""
      # credentials aren't needed for an alert script
      #credentials=""
      node_list=""
      list=""
      master_list=""
      slave_list=""
      synced_list=""
       
      process_arguments()
      {
         while [ "$1" != "" ]; do
            if [[ "$1" =~ ^--initiator=.* ]]; then
               initiator=${1#'--initiator='}
            elif [[ "$1" =~ ^--parent.* ]]; then
               parent=${1#'--parent='}
            elif [[ "$1" =~ ^--children.* ]]; then
               children=${1#'--children='}
            elif [[ "$1" =~ ^--event.* ]]; then
               event=${1#'--event='}
      #      elif [[ "$1" =~ ^--credentials.* ]]; then
      #         credentials=${1#'--credentials='}
            elif [[ "$1" =~ ^--node_list.* ]]; then
               node_list=${1#'--node_list='}
            elif [[ "$1" =~ ^--list.* ]]; then
               list=${1#'--list='}
            elif [[ "$1" =~ ^--master_list.* ]]; then
               master_list=${1#'--master_list='}
            elif [[ "$1" =~ ^--slave_list.* ]]; then
               slave_list=${1#'--slave_list='}
            elif [[ "$1" =~ ^--synced_list.* ]]; then
               synced_list=${1#'--synced_list='}
            fi
            shift
         done
      }
       
      process_arguments $@
       
      read -r -d '' MESSAGE << EOM
      A server has changed state. The following information was provided:
       
      Initiator: $initiator
      Parent: $parent
      Children: $children
      Event: $event
      Node list: $node_list
      List: $list
      Master list: $master_list
      Slave list: $slave_list
      Synced list: $synced_list
      EOM
       
      echo "$MESSAGE" | mail -s "MaxScale received $event event for initiator $initiator." mariadb_admin@domain.com
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              esa.korhonen Esa Korhonen
              Reporter:
              GeoffMontee Geoff Montee
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: