/usr/share/perl5/MMM/Agent/Helpers.pm is in mysql-mmm-agent 2.2.1-1.1.
This file is owned by root:root, with mode 0o664.
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | package MMM::Agent::Helpers;
use strict;
use warnings FATAL => 'all';
use Log::Log4perl qw(:easy);
our $VERSION = '0.01';
=head1 NAME
MMM::Agent::Helpers - an interface to helper programs for B<mmm_agentd>
=cut
=head1 FUNCTIONS
=over 4
=item check_ip($if, $ip)
Check if the IP $ip is configured on interface $if.
Calls B<bin/agent/check_ip>.
=cut
sub check_ip($$) {
my $if = shift;
my $ip = shift;
return _execute('check_ip', "$if $ip");
}
=item configure_ip($if, $ip)
Check if the IP $ip is configured on interface $if. If not, configure it and
send arp requests to notify other hosts.
Calls B<bin/agent/configure_ip>.
=cut
sub configure_ip($$) {
my $if = shift;
my $ip = shift;
return _execute('configure_ip', "$if $ip");
}
=item clear_ip($if, $ip)
Remove the IP address $ip from interface $if.
Calls B<bin/agent/clear_ip>.
=cut
sub clear_ip($$) {
my $if = shift;
my $ip = shift;
return _execute('clear_ip', "$if $ip");
}
=item mysql_may_write( )
Determine wheter writes on local MySQL server are allowes.
Calls B<bin/agent/mysql_may_write>, which reads the config file.
=cut
sub may_write() {
return _execute('mysql_may_write');
}
=item mysql_allow_write( )
Allow writes on local MySQL server. Sets global read_only to 0.
Calls B<bin/agent/mysql_allow_write>, which reads the config file.
=cut
sub allow_write() {
return _execute('mysql_allow_write');
}
=item mysql_deny_write( )
Deny writes on local MySQL server. Sets global read_only to 1.
Calls B<bin/agent/mysql_deny_write>, which reads the config file.
=cut
sub deny_write() {
return _execute('mysql_deny_write');
}
=item turn_on_slave( )
Start slave on local MySQL server.
Calls B<bin/agent/turn_on_slave>, which reads the config file.
=cut
sub turn_on_slave() {
return _execute('turn_on_slave');
}
=item turn_off_slave( )
Stop slave on local MySQL server.
Calls B<bin/agent/turn_off_slave>, which reads the config file.
=cut
sub turn_off_slave() {
return _execute('turn_off_slave');
}
=item sync_with_master( )
Try to sync a (soon active) master up with his peer (old active master) when the
I<active_master_role> is moved. If peer is reachable sync with master log. If
not reachable, sync with relay log.
Calls B<bin/agent/sync_with_master>, which reads the config file.
=cut
sub sync_with_master() {
return _execute('sync_with_master');
}
=item set_active_master($new_master)
Try to catch up with the old master as far as possible and change the master to the new host.
(Syncs to the master log if the old master is reachable. Otherwise syncs to the relay log.)
Calls B<bin/agent/set_active_master>, which reads the config file.
=cut
sub set_active_master($) {
my $new_master = shift;
return "ERROR: Unknown host $new_master" unless (defined($main::config->{host}->{$new_master}));
return _execute('set_active_master', $new_master);
}
#-------------------------------------------------------------------------------
sub _execute($$$) {
my $command = shift;
my $params = shift;
my $return_all = shift;
my $path = $main::agent->bin_path . "/agent/$command";
my $config_file = $main::agent->config_file;
$params = '' unless defined($params);
DEBUG "Executing $path $params";
my $res = `$path $config_file $params`;
unless ($return_all) {
my @lines = split /\n/, $res;
return pop(@lines);
}
return $res;
}
1;
=back
=cut
|