This file is indexed.

/usr/share/perl5/MHA/ManagerAdminWrapper.pm is in mha4mysql-manager 0.55-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env perl

#  Copyright (C) 2011 DeNA Co.,Ltd.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#  Foundation, Inc.,
#  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

package MHA::ManagerAdminWrapper;

use strict;
use warnings FATAL => 'all';

use Getopt::Long qw(:config pass_through);
use MHA::ManagerConst;
use MHA::ManagerAdmin;

my $default_confdir = "/usr/local/masterha/conf";
my $all;
my $app;
my $global_conf = $MHA::ManagerConst::DEFAULT_GLOBAL_CONF;
my $conf;
my $basedir;
my $baselog;
my $internal_basedir;
my $status_dir;
my $logfile;
my $ping_limit = 10;
my $abort;
my $abort_timeout = 5;

sub get_masterha_daemontool_appnames {
  opendir my $dir, "/service";
  my @dirs =
    map { my $s = $_; $s =~ s/^masterha_//; $s }
    grep { m/^masterha_/ } readdir $dir;
  @dirs = sort @dirs;
  closedir $dir;
  return @dirs;
}

sub process_all {
  my $command = shift;
  my @apps    = get_masterha_daemontool_appnames();
  my $ret     = 0;
  foreach my $appname (@apps) {
    $conf = "$default_confdir/$appname.cnf";
    if ($basedir) {
      $status_dir = "$basedir/$appname";
      $app        = $appname;
      undef $conf;
      if ($baselog) {
        $logfile = "$baselog/$appname/$appname.log";
      }
    }
    my $app_ret;
    $app_ret = check_single_app_status() if ( $command == 1 );
    $app_ret = stop_single_app_manager() if ( $command == 2 );
    $ret     = 1                         if ($app_ret);
  }
  return $ret;
}

sub init {
  GetOptions(
    'all'               => \$all,
    'app=s'             => \$app,
    'global_conf=s'     => \$global_conf,
    'conf=s'            => \$conf,
    'basedir=s'         => \$basedir,
    'baselog=s'         => \$baselog,
    'status_dir=s'      => \$status_dir,
    'manager_workdir=s' => \$status_dir,
    'workdir=s'         => \$status_dir,
    'log_output=s'      => \$logfile,
    'manager_log=s'     => \$logfile,
    'ping_limit=i'      => \$ping_limit,
    'abort'             => \$abort,
    'abort_timeout=i'   => \$abort_timeout,
  );
}

sub check_status {
  init();
  if ($all) {
    return process_all(1);
  }
  else {
    if ( $app && !$conf && !$status_dir ) {
      $conf = "$default_confdir/$app.cnf";
    }
    return check_single_app_status();
  }
}

sub stop_manager {
  init();
  if ($all) {
    return process_all(2);
  }
  else {
    if ( $app && !$conf && !$status_dir ) {
      $conf = "$default_confdir/$app.cnf";
    }
    return stop_single_app_manager();
  }
}

sub check_single_app_status {
  return new MHA::ManagerAdmin(
    app         => $app,
    global_conf => $global_conf,
    conf        => $conf,
    status_dir  => $status_dir,
    logfile     => $logfile,
    ping_limit  => $ping_limit
  )->check_status();
}

sub stop_single_app_manager {
  return new MHA::ManagerAdmin(
    app           => $app,
    global_conf   => $global_conf,
    conf          => $conf,
    status_dir    => $status_dir,
    logfile       => $logfile,
    ping_limit    => $ping_limit,
    abort         => $abort,
    abort_timeout => $abort_timeout,
  )->stop_manager();
}

1;