📄 mmm_control
字号:
#!/usr/bin/env perl# Use mandatory external modulesuse strict;use Cwd;use File::Basename;use Data::Dumper;use POSIX;use Config;use Getopt::Long;use threads;use threads::shared;use Thread::Queue;use IO::Socket;use Proc::Daemon;use Time::HiRes;# Check perl for threads support$Config{useithreads} or die "Recompile Perl with threads to run this program.";# Determine installation dir nameour $SELF_DIR = dirname(dirname(Cwd::abs_path(__FILE__)));# Include parts of the systemrequire $SELF_DIR . '/lib/config.pm';require $SELF_DIR . '/lib/log.pm';require $SELF_DIR . '/lib/commands.pm';require $SELF_DIR . '/lib/control.pm';#-----------------------------------------------------------------my $postfix = "";if (scalar(@ARGV) && $ARGV[0] =~ /^@(.*)/) { shift(@ARGV); $postfix = "_$1";}my $cfg_file = "mmm_mon$postfix.conf";unless (-f "$SELF_DIR/etc/$cfg_file") { print "Error: Can't find monitoring system config ($cfg_file)!\n"; print "\tLooks like you are trying to start mmm_control on wrong server or specified wrong cluster name!\n\n"; exit(1);}# Read config fileprint "Config file: $cfg_file\n";our $config = ReadConfig($cfg_file);# Create commands mapour $commands_map = {};$commands_map->{ping} = \&PingCommand;$commands_map->{show} = \&ShowCommand;$commands_map->{set_online} = \&SetOnlineCommand;$commands_map->{set_offline} = \&SetOfflineCommand;$commands_map->{move_role} = \&MoveRoleCommand;# Check paramsif (scalar(@ARGV) < 1) { PrintUsage(); exit(1);}my $command = lc($ARGV[0]);chomp($command);unless ($commands_map->{$command}) { print "Error: Invalid command name: $command!\n"; PrintUsage(); exit(1);}$commands_map->{$command}();exit(0);#-----------------------------------------------------------------sub PrintUsage() { my @command_names = keys(%$commands_map); print "Usage: $0 <" . join('|', @command_names) . "> [..params..]\n\n";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -