~y-trudeau/mysql-mmm/NonBlocking

« back to all changes in this revision

Viewing changes to lib/Monitor/NetworkChecker.pm

  • Committer: Pascal Hofmann
  • Date: 2010-03-09 10:38:27 UTC
  • mfrom: (140.1.5 mysql-mmm-dev)
  • Revision ID: mail@pascalhofmann.de-20100309103827-c9wgc7r8vm39ze1b
  * Added manual mode (bug #531011), wait mode, config values 'mode' and 'wait_for_other_master'
  * Don't die at startup when no network connection is available - wait for it to appear instead (bug #416572)
  * Changed startup behaviour. mmm_mond will only go into passive mode if it detects the active_master_role on more than one host.
  * Added config value 'careful_startup' (bug #422549). If set to 0 mmm_mond won't ever switch into passive mode at startup.
  * Added check for invalid agent commands (prevents crash when mmmd_mon version 1.x talks to an 2.x agent).

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        $checker->shutdown();
55
55
}
56
56
 
57
 
sub initial_check() {
 
57
sub wait_for_network() {
58
58
        my @ips         = @{$main::config->{monitor}->{ping_ips}};
59
 
        my $state       = 0;
60
59
        
61
60
        # Create checker
62
61
        my $checker = new MMM::Monitor::Checker::('ping_ip');
63
62
 
64
 
        # Ping all ips
65
 
        foreach my $ip (@ips) {
66
 
                # Ping checker
67
 
                $checker->spawn() unless $checker->ping();
68
 
 
69
 
                my $res = $checker->check($ip);
70
 
                if ($res =~ /^OK/) {
71
 
                        DEBUG "IP '$ip' is reachable: $res";
72
 
                        $state = 1;
73
 
                        last;
 
63
        while (!$main::shutdown) {
 
64
                # Ping all ips
 
65
                foreach my $ip (@ips) {
 
66
                        last if ($main::shutdown);
 
67
                        # Ping checker
 
68
                        $checker->spawn() unless $checker->ping();
 
69
        
 
70
                        my $res = $checker->check($ip);
 
71
                        if ($res =~ /^OK/) {
 
72
                                DEBUG "IP '$ip' is reachable: $res";
 
73
                                $checker->shutdown();
 
74
                                return 1;
 
75
                        }
74
76
                }
75
 
                DEBUG "IP '$ip' is not reachable: $res";
 
77
 
 
78
                # Sleep a while before checking every ip again
 
79
                sleep($main::config->{monitor}->{ping_interval});
76
80
        }
77
81
        $checker->shutdown();
78
 
 
79
 
        return $state;
 
82
        return 0;
80
83
}
81
84
 
82
85
1;