[Mon-commit] mon CHANGES,1.3.2.11,1.3.2.12 mon,1.22.2.1,1.22.2.2
Brought to you by:
trockij
From: Jim T. <tr...@us...> - 2007-06-06 11:46:29
|
Update of /cvsroot/mon/mon In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14418 Modified Files: Tag: mon-1-2-branch CHANGES mon Log Message: fixed 'disable host' behavior reported by ed ravin Index: CHANGES =================================================================== RCS file: /cvsroot/mon/mon/CHANGES,v retrieving revision 1.3.2.11 retrieving revision 1.3.2.12 diff -C2 -d -r1.3.2.11 -r1.3.2.12 *** CHANGES 3 Jun 2007 20:07:16 -0000 1.3.2.11 --- CHANGES 6 Jun 2007 11:46:17 -0000 1.3.2.12 *************** *** 2,6 **** Changes between mon-1.2.0- and mon-1.2.0-release ! Thu May 10 20:59:34 EDT 2007 ----------------------------------------------- --- 2,6 ---- Changes between mon-1.2.0- and mon-1.2.0-release ! Wed Jun 6 07:45:35 EDT 2007 ----------------------------------------------- *************** *** 49,52 **** --- 49,62 ---- by Jon Meek + -fixed "disable host" behavior. if a host was the only member of a hostgroup, + that watch would be disabled, but that host would not be disabled in other + hostgroups. the correct behavior is that a host will be disabled individually + in all hostgroups, and if it is the only memeber of a hostgroup, the watch + associated with that hostgroup will be disabled. enabling the host again undoes + all of that. the behavior of disabling the watch is useful so that disabling a + host in a single-hosted hostgroup does not inadvertently leave an empty + hostgroup, which will generate log warnings when services are run against it. + reported by Ed Ravin + Changes between mon-1.0.0pre3 and mon-1.0.0pre4 Index: mon =================================================================== RCS file: /cvsroot/mon/mon/mon,v retrieving revision 1.22.2.1 retrieving revision 1.22.2.2 diff -C2 -d -r1.22.2.1 -r1.22.2.2 *** mon 3 May 2007 19:41:24 -0000 1.22.2.1 --- mon 6 Jun 2007 11:46:19 -0000 1.22.2.2 *************** *** 2887,2910 **** } ! if (@notfound == 0) { foreach my $h (@hosts) { ! if (my $g=host_singleton_group($h) ) { disen_watch($g, 0); - $stchanged++; mysystem("$CF{MONREMOTE} disable watch $g") if ($CF{MONREMOTE}); - } else { - disen_host ($h, 0); - $stchanged++; - mysystem("$CF{MONREMOTE} disable host $h") if ($CF{MONREMOTE}); } } sock_write ($fh, "220 disable host completed\n"); } - else - { - sock_write ($fh, "520 disable host failed, @notfound does not exist\n"); - } } else { --- 2887,2915 ---- } ! if (@notfound) ! { ! sock_write ($fh, "520 disable host failed, host(s) @notfound do not exist\n"); ! } ! ! else { foreach my $h (@hosts) { ! # ! # disable a watch if there is a group with this host ! # as its only member. this prevents warning messages ! # about monitors not being run on empty host groups ! # ! foreach my $g (host_singleton_group($h)) { disen_watch($g, 0); mysystem("$CF{MONREMOTE} disable watch $g") if ($CF{MONREMOTE}); } + + disen_host ($h, 0); + $stchanged++; + mysystem("$CF{MONREMOTE} disable host $h") if ($CF{MONREMOTE}); } sock_write ($fh, "220 disable host completed\n"); } } else { *************** *** 2912,2916 **** } - # # enable watch, service or host --- 2917,2920 ---- *************** *** 2951,2963 **** } elsif ($cmd eq "host") { foreach my $h (split (/\s+/, $args)) { ! if (my $g=host_singleton_group($h) ) { disen_watch($g, 1); mysystem("$CF{MONREMOTE} enable watch $g") if ($CF{MONREMOTE}); - $stchanged++; - } else { - disen_host ($h, 1); - mysystem("$CF{MONREMOTE} enable host $h") if ($CF{MONREMOTE}); - $stchanged++; } } sock_write ($fh, "220 enable completed\n"); --- 2955,2966 ---- } elsif ($cmd eq "host") { foreach my $h (split (/\s+/, $args)) { ! foreach my $g (host_singleton_group($h)) { disen_watch($g, 1); mysystem("$CF{MONREMOTE} enable watch $g") if ($CF{MONREMOTE}); } + + disen_host ($h, 1); + mysystem("$CF{MONREMOTE} enable host $h") if ($CF{MONREMOTE}); + $stchanged++; } sock_write ($fh, "220 enable completed\n"); *************** *** 3795,3813 **** } sub host_singleton_group { my $host = shift; ! my $found; foreach my $g (keys %groups) { ! if (grep (/^$host$/, @{$groups{$g}}) && scalar(@{$groups{$g}}) == 1) { ! $found = $g; ! last; } } ! $found; } --- 3798,3823 ---- } + + + # + # given a host, search groups and return an array of group + # names which have that host as their only member. return + # an empty array if no group found + # + # sub host_singleton_group { my $host = shift; ! my @found; foreach my $g (keys %groups) { ! if (grep (/^\*?$host$/, @{$groups{$g}}) && scalar(@{$groups{$g}}) == 1) { ! push (@found, $g); } } ! return (@found); } |