/usr/sbin/mmm_mond is in mysql-mmm-monitor 2.2.1-1.1.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use threads;
use threads::shared;
use Config;
use English qw( PROGRAM_NAME );
use File::Basename;
use POSIX ':sys_wait_h';
use Proc::Daemon;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($INFO);
# Define version and protocol version
use constant MMM_VERSION => '2.2.1';
use constant MMM_PROTOCOL_VERSION => 1;
# Check perl for threads support
$Config{useithreads} or die "Recompile Perl with threads to run this program.";
# Include parts of the system
use MMM::Common::Angel;
use MMM::Common::Config;
use MMM::Common::Log;
use MMM::Common::PidFile;
use MMM::Monitor::Monitor;
use MMM::Monitor::NetworkChecker;
# Maybe we were just asked for our version
if (scalar(@ARGV) && $ARGV[0] eq "--version") {
printf "%s %s\n", basename($PROGRAM_NAME), MMM_VERSION;
exit(0);
}
chdir('/');
umask(0022);
our $cluster_name = '';
my $postfix = '';
if (scalar(@ARGV) && $ARGV[0] =~ /^@(.*)/) {
shift(@ARGV);
$cluster_name = $1;
$postfix = "_$cluster_name";
$PROGRAM_NAME = basename($PROGRAM_NAME) . '-' . $cluster_name;
}
else {
$PROGRAM_NAME = basename($PROGRAM_NAME);
}
MMM::Common::Log::init("mmm_mon_log$postfix.conf", "mmm_mond$postfix");
# Read configuration
our $config = new MMM::Common::Config::;
$config->read("mmm_mon$postfix");
$config->check('MONITOR');
my $debug = $config->{debug};
MMM::Common::Log::debug() if ($debug);
INFO 'STARTING...';
our $monitor = new MMM::Monitor::Monitor::();
my $pidfilename = $config->{monitor}->{pid_path};
my $pidfile = new MMM::Common::PidFile:: $pidfilename;
# Check pid file
LOGDIE "Can't run second copy of ", $PROGRAM_NAME if ($pidfile->is_running());
WARN "Unclean start - found stale pid file!" if ($pidfile->exists());
unless ($debug) {
# Go to background
Proc::Daemon::Init();
# Set umask again
umask(0022);
# Init logging again to re-open fds
MMM::Common::Log::init("mmm_mon_log$postfix.conf", "mmm_mond$postfix");
}
# Init angel magic, which will restart us if we die unexpected
MMM::Common::Angel::Init($pidfile);
our $shutdown :shared = 0; # Shutdown flag
our $have_net :shared = 1; # Network status flag
# Set signal handlers
$SIG{INT} = \&ShutdownHandler;
$SIG{TERM} = \&ShutdownHandler;
$SIG{QUIT} = \&ShutdownHandler;
$SIG{PIPE} = 'IGNORE';
$SIG{CHLD} = \&ChildHandler;
if ($monitor->init()) {
$monitor->main();
}
INFO 'END';
exit(0);
#-----------------------------------------------------------------
sub ShutdownHandler() {
INFO "Signal received: exiting...";
$shutdown = 1;
}
#-----------------------------------------------------------------
sub ChildHandler {
local $!; # don't let waitpid() overwrite current error
while ((my $pid = waitpid(-1, WNOHANG)) > 0 && WIFEXITED($?)) {
DEBUG "Core: reaped child $pid" . ($? ? " with exit $?" : '');
}
$SIG{CHLD} = \&ChildHandler; # loathe sysV
}
|